0

If I'm using a regular Terminal with zsh, I can start any conda environment and the python or ipython commands open the "right" version (on a particular conda env it is Python 3.7.7.). enter image description here

But if I'm on a Terminal under VSCode, I always get a different version, as if it was not assuming the conda environment, although it the prompt shows me the correct conda env. enter image description here Any idea on what might be the problem here?

MrT77
  • 811
  • 6
  • 25
  • Is VSCode using the same zsh terminal? I'm not sure if that would change your path. I couldn't access aliases until I passed in the `shellArgs` flag `-l`. – Steve Mar 17 '21 at 12:15
  • related (duplicates?): https://stackoverflow.com/q/60836646/11107541 https://stackoverflow.com/a/72432622/11107541 – starball May 19 '23 at 06:43

3 Answers3

0

In .vscode/settings.json, you can put the python version required :

{
    "python.pythonPath": "/usr/bin/python3"
}
Philippe
  • 20,025
  • 2
  • 23
  • 32
0

In VS Code, its internal terminal is to integrate the terminal from the system, and it defaults to use the python environment selected in the lower left corner of VS Code when it was created. Therefore, please use the shortcut key Ctrl+Shift+` to open a new VS Code terminal, it will Automatically enter the selected python environment, and for the selected conda environment, it will automatically activate it:

enter image description here

Also, please try to reload VS Code.

Reference: Conda environments in VS Code.

Jill Cheng
  • 9,179
  • 1
  • 20
  • 25
0

Leaving here the answer as I just found it is a known bug.

https://github.com/microsoft/vscode-python/issues/5764

This happens for non-Windows machine and if the selected interpreter is a conda environment and "terminal.integrated.inheritEnv" is not set. Solution is to set "terminal.integrated.inheritEnv" to false.

MrT77
  • 811
  • 6
  • 25