I have Anaconda working on my system and VsCode, but how do I get VsCode to activate a specific environment when I run my python script?
If Anaconda is your default Python installation, then it just works if you install the Microsoft Python extension .
The following should work regardless of the Python editor, or if you need to point to a specific installation:
In settings.json, edit python.path with something like
"python.pythonPath": "C:\\Anaconda3\\envs\\py34\\python.exe"
Instructions for editing settings.json
, , - python.venvPath vscode anavonda envs.
python.venvPath
"python.venvPath": "/Users/[...]/Anaconda3/envs"
, (ctl + shift + P windows/linux, cmd + shift + P mac) Python: Select Workspace Interpreter, envs , , env .
ctl + shift + P
cmd + shift + P
Python: Select Workspace Interpreter
, ( ).
Vscode anaconda, vscode. / :
{ "python.pythonPath": "C:/<proper anaconda path>/Anaconda3/envs/${env:CONDA_DEFAULT_ENV}/python" }
Windows, MacOS , , Unix. vscode: .
, macOS. , export CONDA_DEFAULT_ENV='$HOME/anaconda3/envs/dev' .zshrc "python.pythonPath": "${env.CONDA_DEFAULT_ENV}/bin/python", VSCode, Python, VSCode , .
export CONDA_DEFAULT_ENV='$HOME/anaconda3/envs/dev'
"python.pythonPath": "${env.CONDA_DEFAULT_ENV}/bin/python",
python.pythonPath VSCode settings.json , . Anaconda Microsoft Visual Studio ( VS):
python.pythonPath
settings.json
VS Code Navigator, VS Code Python .
: -prefix:
conda create --prefix C:\your\workspace\root\awesomeEnv\ python=3
VSCode launch.json "pythonPath":
"pythonPath":"${workspaceRoot}/awesomeEnv/python.exe"
python, python.exe anaconda, , python, anaconda python.
, Python env var :
"C:\Anaconda3\envs\py34\", or wherever the python executable lives
, . :)
: https://code.visualstudio.com/docs/python/environments#_conda-environments
As noted earlier, the Python extension automatically detects existing conda environments, provided that the environment contains a Python interpreter. For example, the following command creates a conda environment with a Python 3.4 interpreter and several libraries that VS Code displays in the list of available interpreters:
conda create -n env-01 python=3.4 scipy=0.15.0 astroid babel
On the contrary, if you were unable to specify an interpreter, as in the case of conda create --name env-00, the environment will not appear in the list.