Python Forum
bs4 beautifulsoup4 "module not found" but I confirmed it is installed
Thread Rating:
  • 0 Vote(s) - 0 Average
  • 1
  • 2
  • 3
  • 4
  • 5
bs4 beautifulsoup4 "module not found" but I confirmed it is installed
#1
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
Reply
#2
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.
Recommended Tutorials:
Reply


Possibly Related Threads…
Thread Author Replies Views Last Post
  pyside6 module not found ForeverNoob 4 1,389 Aug-18-2023, 04:36 PM
Last Post: snippsat
  Module Not Found Error bitoded 4 1,402 Jan-01-2023, 09:08 AM
Last Post: bitoded
  pdfminer package: module isn't found Pavel_47 25 8,819 Sep-18-2022, 08:40 PM
Last Post: Larz60+
  Module not found question sighhhh12 0 1,491 Sep-09-2022, 05:43 AM
Last Post: sighhhh12
  [SOLVED] Tkinter module not found Milan 7 23,674 Aug-05-2022, 09:45 PM
Last Post: woooee
  No module found when I run a main.py tomtom 2 1,465 Jul-20-2022, 09:24 AM
Last Post: tomtom
  ModuleNotFound but pip shows module installed biscotty666 2 1,546 Jul-14-2022, 05:17 PM
Last Post: Axel_Erfurt
  Web Scraper with BeautifulSoup4 sometimes no Output Nitsuj 2 1,943 Nov-26-2021, 05:04 PM
Last Post: snippsat
  No Module found in other directory than source code [SOLVED] AlphaInc 1 2,041 Nov-10-2021, 04:34 PM
Last Post: AlphaInc
  No module named 'pysolar' - even tough pysolar is installed - What am I doing wrong? Jghurt 5 4,207 May-08-2021, 07:03 PM
Last Post: Jghurt

Forum Jump:

User Panel Messages

Announcements
Announcement #1 8/1/2020
Announcement #2 8/2/2020
Announcement #3 8/6/2020