Jump to content

I just installed python and then installed. But when I ran the .py file from cmd (windows 10 admin), then I got the following error:

Traceback (most recent call last):
  File "C:\Users\xxxxx\Desktop\scrape.py", line 2, in <module>
    from bs4 import BeautifulSoup as soup
ModuleNotFoundError: No module named 'bs4'

I figured bs4 was not installed properly. So, I have tried all sorts of different variations to install it like:

pip3 install bs4
pip3 install bs4 --upgrade
pip3 install BeautifulSoup
pip3 install BeautifulSoup --upgrade
pip install bs4 --upgrade
pip install BeautifulSoup
pip install BeautifulSoup --upgrade

Nothing helped. It still gives me the same error over and over. What should I do to fix this?

 

 

my code in scrape.py

from urllib.request import urlopen as uReq
from bs4 import BeautifulSoup as soup

my_url = 'xxxxxxxxxxxxxx'
# open connection to website and grab the page
uClient = uReq(my_url)
page_html = uClient.read()
uClient.close()

#html parsing
page_soup = soup(page_html, "html.parser")

data = page_soup.findAll("span", {"class": "desc swap"})

 

Edit: I tried cmd in admin and powershell. same results

Edited by Saksham
Link to comment
https://linustechtips.com/topic/1194652-installing-bs4-for-python/
Share on other sites

Link to post
Share on other sites

15 hours ago, Sauron said:

If you had researched it you'd have discovered that the name of the package is beautifulsoup4.


pip install beautifulsoup4

 

well fuck... doesn't matter anymore. I am using Jsoup instead (java version). I'm more comfortable with java anyway. 

Link to post
Share on other sites

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now

×