"No module named 'requests'" when it is installed

Hi, i’m using python 3.11 in pycharm and get the error “No module named ‘requests’” but this is installed. Can anyone help? thanks

/Users/biancavendone/PycharmProjects/pythonProject/Python-Assignment-2/.venv/bin/python /Users/biancavendone/PycharmProjects/pythonProject/Python-Assignment-2/trivia_game.py
Traceback (most recent call last):
File “/Users/biancavendone/PycharmProjects/pythonProject/Python-Assignment-2/trivia_game.py”, line 3, in
import requests
ModuleNotFoundError: No module named ‘requests’

Process finished with exit code 1

How did you install requests?

You need to ensure it’s installed using the environment your running
your script with, but using pip via the python in the environment.

So in principle this command should do it:

 /Users/biancavendone/PycharmProjects/pythonProject/Python-Assignment-2/.venv/bin/python -m pip install requests

See that it’s using the python from the PyCharm venv?

1 Like

Hi thank you so much that has worked! Where I had gone wrong is I was running the same command from my terminal but not within pycharm. All sorted now so thanks!