I wrote a simple python program that I learned from Mosh Hamedani course.
1- I created a folder called "PyCrawler".
2- Then in my project directory, using terminal, run these commands one by one:
pipenv install beautifulsoup4
pipenv install requests
3- Then it give me an error to install autopep8, so I installed that.
4- created a file named "app.py"
5- selected correspond venv.
6- write these code inside app.py
import requests
from bs4 import BeautifulSoup
response = requests.get("http://stackoverflow.com/questions")
soup = BeautifulSoup(response.text, "html.parser")
questions = soup.select(".question-summary")
print(questions[0].select_one(".question-hyperlink").getText())
7- when I run this program using "python app.py" command it gives me "ModuleNotFoundError: No module named 'bs4' " error.
It's strange. I installed beautifulsoup4, why I got this error?!!
Solutions in other questions that have been asked didn't help me.
I got same issue for selenium.
I think if I install any package I get this issue and I don't know why.
Thanks for your helps in advance.
You are probably installing the packages to a different version of Python than the one you are using to run your program. Before you run your program, enter the command
$ pipenv shell
into your terminal to activate the enviornment. Then
$ python app.py
should work. For more information, see the documentation for pipenv.