Ryijin Ahn
Ryijin Ahn

Reputation: 1

ModuleNotFoundError: No module named 'bs4' sublime text3

I tried pip, pip3, easy_install. I have python 3.7.6.

Code worked the other day, but now it shows traceback:

Traceback (most recent call last): File "C:\Users\RyZen\parsey.py", line 1, in from bs4 import BeutifulSoup as soup

ModuleNotFoundError: No module named 'bs4'

[Finished in 0.6s]

from bs4 import BeutifulSoup as soup
from urllib.request import urlopen as ureq

url1 = 'https://tengrinews.kz/kazakhstan_news/fiktivnyie-scheta-fakturyi-milliard-tenge-vyipisal-403215/'

uclient = ureq(url1)
urlsoup = soup(url1, "html.parser")
uclient.close()

outfile = "parsey.doc"
file = open(outfile, "w")
title =  urlsoup.h1.text.strip()
publishdate = urlsoup.time.text.strip()
contentimage = urlsoup.src="/userdata/news/2020/news_403215/thumb_m/photo_321758.jpeg"

text =urlsoup.findAll("p")
contenttext = ("text[0].text.strip" + "\n" + "text[1].text.strip" 
 + "\n" + "text[2].text.strip" + "\n" + "text[3].text.strip" 
  )
print(title + "\n")
print(publishdate + "\n")
print(contentimage + "\n")
print(contenttext)

file.close()

pip3 install BeautifulSoup4

Requirement already satisfied: BeautifulSoup4 in c:\users\ryzen\anaconda3\lib\site-packages (4.9.1)

Requirement already satisfied: soupsieve>1.2 in c:\users\ryzen\anaconda3\lib\site-packages (from BeautifulSoup4) (1.9.5)

pip3 install bs4

Requirement already satisfied: bs4 in c:\users\ryzen\anaconda3\lib\site-packages (0.0.1)

Requirement already satisfied: beautifulsoup4 in c:\users\ryzen\anaconda3\lib\site-packages (from bs4) (4.9.1)

Requirement already satisfied: soupsieve>1.2 in c:\users\ryzen\anaconda3\lib\site-packages (from beautifulsoup4->bs4) (1.9.5)

Upvotes: 0

Views: 323

Answers (1)

Sam
Sam

Reputation: 116

It's very likely you have conflict versions.

Try isolating your env with virtual env.

pip install virtualenv

On windows cmd at the folder you want your project to be:

virtualenv venv 
venv\Scripts\activate

Now install bs4 for again and try to run your code.

Upvotes: 0

Related Questions