Every time when i try to import the bs4 module i get this error
ModuleNotFoundError: No module named 'bs4'
When i try to install the bs4 module i get this message on the console:
C:\Users\gabri>pip install bs4
Requirement already satisfied: bs4 in c:\users\gabri\appdata\local\programs\python\python39\lib\site-packages (0.0.1)
Requirement already satisfied: beautifulsoup4 in c:\users\gabri\appdata\local\programs\python\python39\lib\site-packages (from bs4) (4.9.3)
Requirement already satisfied: soupsieve>1.2 in c:\users\gabri\appdata\local\programs\python\python39\lib\site-packages (from beautifulsoup4->bs4) (2.2.1)
When i try to import the requests module that's working i get this message:
C:\Users\gabri>pip install bs4
Requirement already satisfied: bs4 in c:\users\gabri\appdata\local\programs\python\python39\lib\site-packages (0.0.1)
Requirement already satisfied: beautifulsoup4 in c:\users\gabri\appdata\local\programs\python\python39\lib\site-packages (from bs4) (4.9.3)
Requirement already satisfied: soupsieve>1.2 in c:\users\gabri\appdata\local\programs\python\python39\lib\site-packages (from beautifulsoup4->bs4) (2.2.1)
My python version is:
Python 3.9.5
My pip version is:
pip 21.1.2 from c:\users\gabri\appdata\local\programs\python\python39\lib\site-packages\pip (python 3.9)
I used to have anaconda installed and then i installed python again. I read in some post that maybe the problem was happening because of two versions of python installed than i uninstall anaconda and jupyter. However nothing change. Some people said to me that my pip was install in another python besides the one i am trying to run, but i dont know how to change that. The code i'm trying to run in this
import requests as r
from bs4 import BeautifulSoup
try:
result = r.get('https://www.google.com.br/search?q=Python')
except Exception as err:
print("Something went wrong: ",err)
else:
response = result.text
soup = BeautifulSoup(response,'html.parser')
print(soup.title)
print(soup.title.string)
And the error is this:
>>> %Run teste.py
Traceback (most recent call last):
File "C:\Users\gabri\teste.py", line 2, in <module>
from bs4 import BeautifulSoup
ModuleNotFoundError: No module named 'bs4'
I think that my pip is install in this path:
pip 21.1.2 from c:\users\gabri\appdata\local\programs\python\python39\lib\site-packages\pip (python 3.9)
and my python is install in this path:
C:\Users\gabri\AppData\Local\Programs\Python\Python39\python39.zip
C:\Users\gabri\AppData\Local\Programs\Python\Python39\DLLs
C:\Users\gabri\AppData\Local\Programs\Python\Python39\lib
C:\Users\gabri\AppData\Local\Programs\Python\Python39
C:\Users\gabri\AppData\Local\Programs\Python\Python39\lib\site-packages
Thats a picture of my paths on windows
I try put the file with the code that i'm trying to run inside the path of bs4 and it worked. But i would like to know if there is an easy method besides that