vscode activates conda but points to the default python
See original GitHub issueEnvironment data
- VS Code version: 1.31.1 (1.31.1)
- Extension version (available under the Extensions sidebar): 2019.1.0
- OS and version: MacOS 10.14.3 (18D42)
- Python version (& distribution if applicable, e.g. Anaconda): Python 3.6, conda 4.6.4
- Type of virtual environment used (N/A | venv | virtualenv | conda | …): conda
Expected behavior
when conda activate env
, anaconda’s python is used. this works in the shell terminal
Actual behavior
when conda activate env
, terminal states that env is activated - prints (env)
at the beginning of the line. Same with the interpreter - VScode sees it and I am able to select it.
However, which python
points to the default python on MacOS, and therefore none python 3.6-dependent packages work. Same with the interpreter - VScode fails to find packages which are installed in the env
Steps to reproduce:
- conda env create -n py36 python=3.6 luigi
- conda activate py36
- which python // in vscode terminal
Logs
Output for Python
in the Output
panel (View
→Output
, change the drop-down the upper-right of the Output
panel to Python
)
___________________ ERROR collecting tests/test_reporter.py ____________________
ImportError while importing test module '/Users/philippk/Dropbox/se_projects/4_Automation/SERJ/tests/test_reporter.py'.
Hint: make sure your test modules/packages have valid Python names.
Traceback:
test_reporter.py:5: in <module>
from SE.areas import get_all_areas
E ModuleNotFoundError: No module named 'SE'
!!!!!!!!!!!!!!!!!!! Interrupted: 3 errors during collection !!!!!!!!!!!!!!!!!!!!
PROBLEMS similarly complains about lack of packages installed and type hints.
Output from Console
under the Developer Tools
panel (toggle Developer Tools on under Help
; turn on source maps to make any tracebacks be useful by running Enable source map support for extension debugging
)
(base) ZG00021:SERJ philippk$ conda activate py36
(py36) ZG00021:SERJ philippk$ which python
/usr/local/bin/python
(py36) ZG00021:SERJ philippk$ conda --version
conda 4.6.4
Issue Analytics
- State:
- Created 5 years ago
- Comments:11
Top GitHub Comments
Yes. But I may do it this weekend.
Find some dark magic for workaround. In case someone with the same problem need a solution. As long as you ADD some stuff to configuration,
terminal.integrated.env.osx
, the content will be appended to PATH after shell initialization(source bash_profile or zshrc). In my Mojave, I simply add following empty entry to my user configuration:Then the $PATH will be the same as the external terminal.
Too busy to dive into the source code to check the root cause, maybe do it later when I have more time.