1

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.

sinoroc
  • 18,409
  • 2
  • 39
  • 70
gimi
  • 395
  • 3
  • 13
  • 1
    Does this [github issue](https://github.com/beeware/briefcase/issues/559#issuecomment-896369811) help you? They're having a similar issues as you, but with another module. – Marcelo Paco Apr 03 '23 at 01:53
  • Maybe provide a [mre], in order to make it easier for others to help you. – sinoroc Apr 03 '23 at 08:00
  • @MarceloPaco I get the same errors even after following all those steps – gimi Apr 04 '23 at 00:42

1 Answers1

3

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:

mhsmith
  • 6,675
  • 3
  • 41
  • 58
  • I should have specified that I still get the error even when adding the -r option. So, unfortunately, that did not solve my issue. – gimi Apr 04 '23 at 00:40
  • Then please create an issue on the [Briefcase GitHub page](https://github.com/beeware/briefcase/issues), and make sure you include the log of `briefcase run -r`, and the relevant sections of your pyproject.toml file. – mhsmith Apr 04 '23 at 08:02
  • My bad, I had added the requirements under `test_sources` instead of `requires`. Marking your answer as correct because it helped me identify the issue! – gimi Apr 04 '23 at 19:19