问题
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:
- I initially saw this issue Conda and Visual Studio Code debugging because I thought since it was pointing at base (or at least displaying wrong names) that it didn't recognize or know where my conda path was so that question seemed useful but ended up not fixing the naming issues.
- Initially I also thought that it might have been related to a conda init issue I had exactly 30 days ago but it wasn't related unfortuantely Why is conda init updating my .bash_profile incorrectly?
Per comment request to check inheritEnv
:
the box is unchecked which I assume means "terminal.integrated.inheritEnv"
is set to false
回答1:
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
回答2:
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
来源:https://stackoverflow.com/questions/61466629/how-to-have-conda-commands-match-behaviour-in-vscodes-integrated-terminal-and-n