Python Forum

Full Version: bs4 beautifulsoup4 "module not found" but I confirmed it is installed
You're currently viewing a stripped down version of our content. View the full version with proper formatting.
I'm working out of "Automate the Boring Stuff with Python" 2nd edition (about two-thirds down on this page https://automatetheboringstuff.com/2e/chapter12/)

I installed python 3.8 on a new windows machine (surface pro 6)

I'm a novice at python and programming in general

Working in Mu (per book instructions) but also the command line

I installed, uninstalled, and re-installed bs4 in the same fashion that I installed other modules which appear to be working.

### Below shows uninstall bs4 and then re-install, copy/pasted from command line ###

C:\Users\USER\AppData\Local\Programs\Python\Python38\Scripts>pip uninstall beautifulsoup4 Found existing installation: beautifulsoup4 4.7.1 Uninstalling beautifulsoup4-4.7.1: Would remove: c:\users\USER\appdata\roaming\python\python38\site-packages\beautifulsoup4-4.7.1.dist-info\* c:\users\USER\appdata\roaming\python\python38\site-packages\bs4\* Proceed (y/n)? y Successfully uninstalled beautifulsoup4-4.7.1 C:\Users\USER\AppData\Local\Programs\Python\Python38\Scripts>pip install beautifulsoup4 Collecting beautifulsoup4 Downloading beautifulsoup4-4.8.2-py3-none-any.whl (106 kB) |████████████████████████████████| 106 kB 1.1 MB/s Requirement already satisfied: soupsieve>=1.2 in c:\users\USER\appdata\roaming\python\python38\site-packages (from beautifulsoup4) (1.9.5) Installing collected packages: beautifulsoup4 Successfully installed beautifulsoup4-4.8.2

### above is from command line ###

However, when I run this code (per the book and link in the opening of this post):

import requests, bs4
res = requests.get('https://nostarch.com')
res.raise_for_status()
noStarchSoup = bs4.BeautifulSoup(res.text, 'html.parser')
type(noStarchSoup)

I get this error in Mu:

Traceback (most recent call last):
File "c:\users\USER\mu_code\bs4tests.py", line 1, in <module>
import requests, bs4
ModuleNotFoundError: No module named 'bs4'

I've googled this several times and not seen a solution that solves my specific issue.

Appreciate any help - thx
install bs4 via
pip install bs4
then in your command prompt run
python
to get the python interpreter. Make sure it says python 3.8
then type at the >>> prompt
import bs4
If you get another >>> prompt it works. Then make sure that any IDE you are using is using the python3.8 interpreter as opposed to any other that does not have bs4 installed.