question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

vscode activates conda but points to the default python

See original GitHub issue

Environment 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:

  1. conda env create -n py36 python=3.6 luigi
  2. conda activate py36
  3. which python // in vscode terminal

Logs

Output for Python in the Output panel (ViewOutput, 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:closed
  • Created 5 years ago
  • Comments:11

github_iconTop GitHub Comments

3reactions
praenubiluscommented, Feb 28, 2019

@praenubilus Are you planning to open a pull request in the VSCode repo to get this fixed?

Yes. But I may do it this weekend.

3reactions
praenubiluscommented, Feb 23, 2019

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:

"terminal.integrated.env.osx": {
		"PATH": ""
}

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.

Read more comments on GitHub >

github_iconTop Results From Across the Web

Using Python environments in VS Code
Conda environments can't be automatically activated in the VS Code Integrated Terminal if the default shell is set to PowerShell. To change the...
Read more >
Efficient Way to Activate Conda in VSCode - Medium
Option 2: Run “conda activate <env-name>” in terminal · CTRL+SHIFT+P open “Preference: Open User Settings (JSON)”. We choose User settings instead of Workspace ......
Read more >
Activating Anaconda Environment in VsCode - Stack Overflow
Firstly, open the command palette using Ctrl + Shift + P · Secondly, Select Python: select Interpreter · Now, Select Enter interpreter path...
Read more >
Vscode activates conda but points to the default python
1. Open settings. Open Settings · 2. Modify configuration. Add following content to configuration "terminal.integrated.env.osx": { "PATH": "" }.
Read more >
Configure VSCode and a cloned ArcGIS Pro Conda env...
I can choose my default interpreter just fine by pointing to the python.exe inside my cloned conda environment, however the indicator at the ......
Read more >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found