0

When I run import requests I receive an error: ImportError: No module named requests. I have looked at other responses to similar questions and tried nearly everything and nothing is working. I'm using MacOS and my project is on my desktop in a folder with a single file with the one line of code I wrote above. When I run pip3 list, the request package is installed.

mberge
  • 57
  • 5

1 Answers1

0

I understand you, python can be a mess. Macos has a default installation of python version 2.XX when you type 'python' in terminal it executes the preinstalled python v2

Now since you are using pip3 I assume you've installed latest python 3.XX and pip3 will install modules for python 3 only not for the default python 2

So when you are running your script.py, insted of python script.py try python3 script.py

  • Thank you! I realize now what the problem was after your comment. I'm using VS Code and I'm using the Code Runner extension which when clicked, most likely maps to the wrong version of Python to run the script. – mberge Jan 21 '22 at 05:25