Trying to figure out Python with Visual Studio on Mac. Dependencies and Libraries don't seem to install/launch correctly.
How To Install Python For Visual Studio Machine
Install Tensorflow with Virtuelenv and Visual Studio Code on Mac. Test if the installation has worked python. Set up Visual Studio Code. Install the Visual Studio Python Extension.
For example, I have pandas on my system, installed via pip, and if I do
from a Python prompt, it works fine.
With Visual Studio Code, if I create a file with the above code, autocomplete recognizes that pandas is installed
When I try to run, I get an ImportError: No module named pandas
Any ideas?
Update: It works in VSCode's terminal, just not when I run the code in the debugger.
1 Answer
Laurence Moroney is right -- this issue occurs when VS Code is using a Python interpreter different from the one that has your libraries installed.
See Configuring Python Environments for instructions on changing the interpreter globally in VS Code. Don't forget to restart VS Code afterwards.
Not the answer you're looking for? Browse other questions tagged pythonvisual-studio-code or ask your own question.
I cannot seem to get Python3 to work when debugging it continues to use Python2. I've tried a few things but still am unable to get it work. I verified Python3s path is /usr/local/bin/python3Everytime I run a script to by
I still get 2.7.10python 3 is installed and work correctly.
I have this in my launch.json and settings.json (type and request are both grayed out for some reason in the launch.json)
Suraj Rao
4 Answers
To select a specific python interpreter, invoke the Python: Select Interpreter command from the Command Palette (⇧⌘P).
This will update your .vscode/settings.json file:
You should then be able to debug using python 3 interpreter or any other python interpreter is available on your machine.
kimbaudi
kimbaudi
This is not an answer, but my rep won't allow a comment:For me your proposed solution worked just fine. Here some troubleshooting:
- Did you change the original launch.json entry? Then you probably need to reload it, which should happen automatically, but restarting VSCode will do that for sure.
- Also, I would recommend using the 'Add Configuration' button, then choose 'python', and edit the name in the new entry (from 'Python' to 'Python3') as not to clash with the old python entry, as well as change the 'pythonPath' key's value from '${config:python.pythonPath}' to '/usr/local/bin/python3'
To use this config, select in the Debug dropdown box.
if you use 'code runner',you can try to open user settings with command palette.
it's work for me.
V-rund Puro-hit
What worked for me is adding the following to User Settings:
kimbaudi
Lech Migdal
Lech Migdal