Python Forum
Strange ModuleNotFound Error on BeautifulSoup for Python 3.11 - Printable Version

+- Python Forum (https://python-forum.io)
+-- Forum: Python Coding (https://python-forum.io/forum-7.html)
+--- Forum: Web Scraping & Web Development (https://python-forum.io/forum-13.html)
+--- Thread: Strange ModuleNotFound Error on BeautifulSoup for Python 3.11 (/thread-40190.html)



Strange ModuleNotFound Error on BeautifulSoup for Python 3.11 - Gaberson19 - Jun-17-2023

Hi, first time poster here.

So I've been trying Beautiful Soup for the first time, but when I tried running my code, I ended up getting a ModuleNotFound error.

[Image: image.png?width=895&height=425]

I've been looking for other posts online and tried uninstalling and reinstalling BeautifulSoup, and even reinstalling it through Windows Shell but to no avail. (Even restarted my IDE, using Visual Studio here)

Checked my paths, they should also be in the clear as well

[Image: image.png?width=895&height=196]

I even checked, they're both running on python 3.11
[Image: image.png?width=895&height=95]

The Versions of Pip and BeautifulSoup are noted to be in their latest versions as well.

I tried fiddling things around and apparently found out that the error disappears when I run the code instead on Python 3.1
[Image: image.png?width=895&height=250]

which I don't really know why this happened. I would love some help in understanding the situation.


RE: Strange ModuleNotFound Error on BeautifulSoup for Python 3.11 - Gaurav_Kumar - Jul-13-2023

See the problem is coming due to different versions of beautifulsoup4 and python.
You have to install these external modules according to the latest versions.

For example:- if you are using bs4 version:-4.7.0 with python version:-3.7 then in this case the version of beautifulsoup is not compatible with python version

To overcome this issue follow these steps:-
1.> Upgrade the version of beautifulsoup4 by running this command in your code editor terminal or command prompt
pip install --upgrade beautifulsoup4

2.> Verify your python version by running this command
python --version

3.> Check correct installation location of bs4 in Python environment by running this command
pip show beautifulsoup4

By following these steps you will understand that what was the situation.

If still the above steps will not work for you then follow this approach:-

1.> run this command
pip install bs4

2.> pip install requests

3.> if you have already executed pip install beautifulsoup4 then its ok along with it run pip install bs4

See i have also executed your python script and on my system its perfectly working visit this screenshot link:-
https://prnt.sc/mUQE_MhKZS1x
[attachment=2453]