본문 바로가기

카테고리 없음

How To Install Python For Visual Studio Mac



Active1 year, 7 months ago

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

Mac

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.

Laurence Moroney
Laurence MoroneyLaurence Moroney

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.

Bernd VerstBernd Verst
Got a question that you can’t ask on public Stack Overflow? Learn more about sharing private information with Stack Overflow for Teams.

Not the answer you're looking for? Browse other questions tagged pythonvisual-studio-code or ask your own question.

Active1 year, 1 month ago

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

25.3k8 gold badges65 silver badges76 bronze badges
SeanJohnSeanJohn

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

Qbittorrent

kimbaudi

3,2785 gold badges28 silver badges42 bronze badges

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.

TascheTasche

if you use 'code runner',you can try to open user settings with command palette.

Install

it's work for me.

V-rund Puro-hit

4,3768 gold badges21 silver badges47 bronze badges
謝騰緯謝騰緯

What worked for me is adding the following to User Settings:

kimbaudi

3,2785 gold badges28 silver badges42 bronze badges

Lech Migdal

Lech Migdal

How To Install Python For Visual Studio Mac Download

1,9352 gold badges22 silver badges41 bronze badges

Visual Studio For Mac

Not the answer you're looking for? Browse other questions tagged pythonjsonmacospython-3.xvisual-studio-code or ask your own question.