pythonbeautifulsouppython-importpython-venvbeeware

Using BeautifulSoup in a BeeWare app gives `ModuleNotFoundError: No module named 'bs4'


I am trying to import beautifulsoup4in a BeeWare app (with its own virtual environment) using the command:

from bs4 import BeautifulSoup

But I get a ModuleNotFoundError: No module named 'bs4' even though I have installed beautifulsoup4 in my virtual environment and added it to the dependencies in my pyproject.toml file. What's the issue then? Solutions I have found for regular virtual environments do not seem to apply to BeeWare apps. The issue only arises when I run the briefcase run command, but not with briefcase dev.


Solution

  • briefcase dev runs the app within your current environment, but briefcase run uses a separate environment containing only the requirements in your pyproject.toml file. Whenever you change that requirements list, you'll have to update the app's environment by adding the -r option to the briefcase run command.

    For more details, see: