Scott.J.G
Scott.J.G

Reputation: 11

ImportError: No module named bs4 - despite bs4 and BeautifulSoup being installed

I downloaded Python 3.7 and am running a script with "from bs4 import BeautifulSoup" and am receiving the following error on execution;

"File "myscript.py", line 3, in from bs4 import BeautifulSoup ImportError: No module named bs4"

When I type "pip3 install bs4" or "pip3 install BeautifulSoup4" in the terminal I get the following;

"Requirement already satisfied: bs4 in /Library/Frameworks/Python.framework/Versions/3.7/lib/python3.7/site-packages (0.0.1) Requirement already satisfied: beautifulsoup4 in /Library/Frameworks/Python.framework/Versions/3.7/lib/python3.7/site-packages (from bs4) (4.6.3)"

Executing "import bs4" and "from bs4 import BeautifulSoup" in IDLE don't error out.

Any idea about what's going on?

Upvotes: 0

Views: 1791

Answers (3)

Zoran
Zoran

Reputation: 1

I had a similar problem with importing bs4. There is a similar question with many answers. I tried many things and nothing worked but when I installed poetry [https://python-poetry.org/ ] $ poetry add pendulum It sorted dependencies for me so I was able to import bs4.

Upvotes: 0

Sandiph Bamrel
Sandiph Bamrel

Reputation: 147

check if you have more than one version of python, if so add the path of python 3.7 in the system setting and try removing the older python if possible and then pip install BeautifulSoup

Upvotes: 1

ksha
ksha

Reputation: 2087

Just pip install bs4. Probably, you are maintaining different versions of Python.

Upvotes: 2

Related Questions