Reputation: 120
I am having a problem running my script in Visual Studio Code.
I have tried the following:
pip
, easy_install
, and sudo pip
requests
directly in the Python interpreter (which worked)This leads me to believe that Visual Studio Code isn't using the correct interpreter that actually has the package installed.
Upvotes: 2
Views: 6508
Reputation: 196
I think yours is a Python environment problem. To check whether it's Python environment or not, you can use which python
(or which python3
if you use Python 3) command in your both Visual Studio Code terminal and Mac terminal. If you see different python path, then your Visual Studio Code is using different python environment. You can change the Python interpreter in Visual Studio Code to have same environment as your Mac terminal.
Then, choose the same environment as your Mac terminal (if you want the same one, you can choose the same Python environment path as Mac terminal that you get with "which python" or "which python3").
Upvotes: 1
Reputation: 71
You may be able to find a solution here: ImportError: No module named requests
You haven't mentioned using different versions in your commands. It's possible you need to use pip3
instead of pip
, or python3
instead of python
.
Upvotes: 0
Reputation: 861
You can choose your interpreter in VS Code in several ways. One of them is by clicking the tab in the bottom toolbar (lower-left) which might say "Python 3.9.4 (64-bit)", upon which you will be able to select from a menu of choices, e.g. /usr/bin/python3 or a conda or brew installation, etc.
Upvotes: 2