Reputation: 5199
I was put off because conda info --envs
does NOT display the same thing that my terminal does. Terminal:
(automl) brandBrandoParetoopareto~/anaconda3/envs $ conda info --envs
# conda environments:
#
base /Users/brandBrandoParetoopareto/anaconda3
automl * /Users/brandBrandoParetoopareto/anaconda3/envs/automl
coqgym /Users/brandBrandoParetoopareto/anaconda3/envs/coqgym
vscode integrated terminal outpute:
(automl) brandBrandoParetoopareto~/ultimate-utils $ conda info --envs
# conda environments:
#
/Users/brandBrandoParetoopareto/anaconda3
base * /Users/brandBrandoParetoopareto/anaconda3/envs/automl
/Users/brandBrandoParetoopareto/anaconda3/envs/coqgym
it is really strange because it seems to be using the right env which I would have not know because in the debugger window it does not show (automl)
but says (base)
but points to the right env (In fact the previous command output if you read it carefully says it's using (automl)
but then it's actually using base
BUT it seems to be pointing to the right environment!?!? But wrong names).
This seems like weird behavior does anyone know how to fix this or if it's causing other unexpected issues?
Perhaps this should be posted in vscode issues but I couldn't figure out which one since there is a vscode and a vscode-python one too.
Related issue:
Per comment request to check inheritEnv
(to get to it go to settings then in search bar type inheritEnv
):
the box is unchecked which I assume means "terminal.integrated.inheritEnv"
is set to false
The weird thing I am seeing now is that:
zsh
to start a new prompt, the bottom left does not seem to point to the right conda env.Upvotes: 3
Views: 1664
Reputation: 4809
Have you set the python environment in VScode? If not explicitly it picks the first python it can find according to it's python search algorithm.
The Status Bar always shows the current interpreter.
To select a specific environment, use the Python: Select Interpreter command from the Command Palette (Ctrl+Shift+P).
This interpreter will be saved in the workspace settings:
Selecting an interpreter from the list adds an entry for python.pythonPath with the path to the interpreter inside your Workspace Settings. Because the path is part of the workspace settings, the same environment should already be selected whenever you open that workspace. If you'd like to set up a default interpreter for your applications, you can instead add an entry for python.pythonPath manually inside your User Settings. To do so, open the Command Palette (Ctrl+Shift+P) and enter Preferences: Open User Settings. Then set python.pythonPath, which is in the Python extension section of User Settings, with the appropriate interpreter.
Caveats:
Conda environments can't be automatically activated in the VS Code Integrated Terminal if the default shell is set to PowerShell. To change the shell, see Integrated terminal - Configuration.
Conda environment in your project will be used, but only if the conda environment contains the python interpreter, by setting python=
when creating the conda environment:
conda create -n env-01 python=3.4
For further details check the python environments section of the VSCode documentation. https://code.visualstudio.com/docs/python/environments
Upvotes: 1
Reputation: 974
My recommendation would be to simply set VS Code to use the shell you are using normally: How to change the integrated terminal in visual studio code or VSCode
Upvotes: 1