1

I have installed iTerm with ohmyzsh and all work like a charm :

When I have tried to use Python in the same way in visual studio code, it is the 2.7 version which is launched :

enter image description here

I have selected the good interpreter (conda 3.7) and I can't understand why the python version is different.

Here is my settings.json from VScode:

{
    "terminal.external.osxExec": "iTerm.app",
    "terminal.integrated.shell.osx": "/bin/zsh",
    "terminal.integrated.fontFamily": "MesloLGS NF",
}
Jonor
  • 1,102
  • 2
  • 15
  • 31
  • related (duplicates?): https://stackoverflow.com/a/72432622/11107541 https://stackoverflow.com/q/66670568/11107541 – starball May 19 '23 at 06:42

1 Answers1

2

If you echo $PATH I am sure they will end up being different. For instance, if you activated a conda environment that would change what python points at by changing your PATH.

But in general, you do not want to rely on the python command unless you are in an activated environment as you won't know what version of Python to use. It's better to either be working in an activated environment, specify the full path to the Python interpreter, or at least specify the Python version (e.g. python3.7).

Brett Cannon
  • 14,438
  • 3
  • 45
  • 40
  • Yes, the two path are quite different. (`/Users/n.beau/bin:/usr/local/bin:/usr/local/bin:/usr/bin:/bin:/usr/sbin:/sbin:/Users/n.beau/opt/anaconda3/bin:/Users/n.beau/opt/anaconda3/condabin:/Users/n.beau/bin` and `/Users/n.beau/opt/anaconda3/bin:/Users/n.beau/opt/anaconda3/condabin:/Users/n.beau/bin:/usr/local/bin:/usr/local/bin:/usr/bin:/bin:/usr/sbin:/sbin`). But as I import my iTerm terminal in VScode, how the behaviour can be different ? – Jonor Mar 26 '20 at 09:10
  • I have changed my $PATH from VScode to become the same as iTerm, however when I run `python`, I get the same problem. – Jonor Mar 26 '20 at 09:31
  • 1
    It looks like you activated your conda environment in one and not the other which will change what Python resolves to. There's also the question as to whether you are using the same shell in both terminals. Honestly my best piece of advice is to never just type `python` unless you're in an activated environment. Otherwise at least specify the Python version (e.g. `python3.8` or `python3`), best is specifying the whole path. – Brett Cannon Mar 26 '20 at 21:48