Description
Environment data
- VS Code version: 1.31.1
- Extension version (available under the Extensions sidebar): 2019.1.0
- OS and version: OSX Sierra 10.12.6
- Python version (& distribution if applicable, e.g. Anaconda): Miniconda, Python 3.6.7
- Type of virtual environment used (N/A | venv | virtualenv | conda | ...): conda
Expected behaviour
- Select conda environment python as Python Interpreter (i.e. for my environment called
ads
,~/miniconda/envs/ads/bin/python
) - Open new terminal
which python
returns path to selected Python Interpreter (~/miniconda/envs/ads/bin/python
)
Actual behaviour
- Select conda environment python as Python Interpreter
- Open new terminal
which python
returns system python (/usr/bin/python
)
Steps to reproduce:
- Create new conda environment with
conda create -n ads python=3.6
- Select environment python as Python Interpreter
- Open new terminal
- Type
which python
Logs
Here's what my terminal looks like when I open a new one. The source .../activate
and conda activate ads
commands happened automatically and the other ones were from me.
╭─benlindsay@huntsman-ve501-0393:dmft-adsorbing-polymer/ (master*)
╰─$ source /Users/benlindsay/miniconda/bin/activate
conda activate ads
(base) ╭─benlindsay@huntsman-ve501-0393:dmft-adsorbing-polymer/ (master*)
╰─$ conda activate ads
(ads) ╭─benlindsay@huntsman-ve501-0393:dmft-adsorbing-polymer/ (master*)
╰─$ which python
/usr/bin/python
(ads) ╭─benlindsay@huntsman-ve501-0393:dmft-adsorbing-polymer/ (master*)
╰─$ python --version
Python 2.7.10
(ads) ╭─benlindsay@huntsman-ve501-0393:dmft-adsorbing-polymer/ (master*)
╰─$ echo $PATH | tr : '\n'
/Users/benlindsay/.rvm/gems/ruby-2.3.0/bin
/Users/benlindsay/.rvm/gems/ruby-2.3.0@global/bin
/Users/benlindsay/.rvm/rubies/ruby-2.3.0/bin
/Users/benlindsay/.local/bin
/usr/local/bin
/Applications/R.app/Contents/MacOS
/Applications/RStudio.app/Contents/MacOS
/Applications/Ovito.app/Contents/MacOS
/usr/local/bin
/usr/bin
/bin
/usr/sbin
/sbin
/opt/X11/bin
/Library/TeX/texbin
/Users/benlindsay/miniconda/envs/ads/bin
/Users/benlindsay/miniconda/condabin
/Users/benlindsay/.rvm/gems/ruby-2.3.0/bin
/Users/benlindsay/.rvm/gems/ruby-2.3.0@global/bin
/Users/benlindsay/.rvm/rubies/ruby-2.3.0/bin
/Users/benlindsay/.local/bin
/Applications/R.app/Contents/MacOS
/Applications/RStudio.app/Contents/MacOS
/Applications/Ovito.app/Contents/MacOS
/Users/benlindsay/.rvm/bin
For comparison, here's what it looks like if I open iterm2 and type the same things in:
╭─benlindsay@huntsman-ve501-0393:~/
╰─$ source /Users/benlindsay/miniconda/bin/activate
(base) ╭─benlindsay@huntsman-ve501-0393:~/
╰─$ conda activate ads
(ads) ╭─benlindsay@huntsman-ve501-0393:~/
╰─$ which python
/Users/benlindsay/miniconda/envs/ads/bin/python
(ads) ╭─benlindsay@huntsman-ve501-0393:~/
╰─$ python --version
Python 3.6.7 :: Anaconda, Inc.
(ads) ╭─benlindsay@huntsman-ve501-0393:~/
╰─$ echo $PATH | tr : '\n'
/Users/benlindsay/miniconda/envs/ads/bin
/Users/benlindsay/.rvm/gems/ruby-2.3.0/bin
/Users/benlindsay/.rvm/gems/ruby-2.3.0@global/bin
/Users/benlindsay/.rvm/rubies/ruby-2.3.0/bin
/Users/benlindsay/miniconda/condabin
/Users/benlindsay/.local/bin
/usr/local/bin
/Applications/R.app/Contents/MacOS
/Applications/RStudio.app/Contents/MacOS
/Applications/Ovito.app/Contents/MacOS
/usr/local/bin
/usr/bin
/bin
/usr/sbin
/sbin
/opt/X11/bin
/Library/TeX/texbin
/Users/benlindsay/.rvm/bin
So /Users/benlindsay/miniconda/envs/ads/bin
was correctly added to PATH
but it appears that my .zshrc
was sourced again after doing so, which added duplicates of some paths in front of it, including /usr/bin
, so that now the system python is the default interpreter instead of the conda environment interpreter. Maybe getting rid of that extra sourcing of the user's configuration file would fix the problem?
There appear to be some similar issues, like #4402, #2952, and #4077, but this one seems different in that the terminal appears to be successfully running the right commands, but having some PATH
issues.