Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Miniconda environment is activated after debugging starts #14340

Closed
aykutkilic opened this issue Oct 9, 2020 · 3 comments
Closed

Miniconda environment is activated after debugging starts #14340

aykutkilic opened this issue Oct 9, 2020 · 3 comments
Assignees
Labels
bug Issue identified by VS Code Team member as probable bug

Comments

@aykutkilic
Copy link

Environment data

  • VS Code version: 1.49.3
  • Extension version (available under the Extensions sidebar): v2020.9.114305
  • OS and version: Win10-64
  • Python version (& distribution if applicable, e.g. Anaconda): 3.6.9-64 / miniconda/3-4.7.12
  • Type of virtual environment used (N/A | venv | virtualenv | conda | ...): conda 4.8.3
  • Relevant/affected Python packages and their versions: XXX
  • Relevant/affected Python-related VS Code extensions and their versions: XXX
  • Value of the python.languageServer setting: XXX

[NOTE: If you suspect that your issue is related to the Microsoft Python Language Server (python.languageServer: 'Microsoft'), please download our new language server Pylance from the VS Code marketplace to see if that fixes your issue]

Expected behaviour

  1. I press F5 and start debugging
  2. Debugging start as expected

Actual behaviour

  1. Press F5 and start debugging.
  2. Import numpy fails
    image
  3. miniconda is not started in terminal
  4. Stop debugging
  5. miniconda is activated automatically
  6. switch back to debugged file and press f5
  7. debugging works normally

Steps to reproduce:

[NOTE: Self-contained, minimal reproducing code samples are extremely helpful and will expedite addressing your issue]

  1. Make sure the terminal is closed
  2. Make sure python is not in path
  3. Create a conda env that contains numpy
  4. Create a python file imports numpy
  5. Open it, press F5 and start debugging file

Logs

Output for Python in the Output panel (ViewOutput, change the drop-down the upper-right of the Output panel to Python)

XXX

@aykutkilic aykutkilic added triage-needed Needs assignment to the proper sub-team bug Issue identified by VS Code Team member as probable bug labels Oct 9, 2020
@karthiknadig
Copy link
Member

This is a known issue with activating conda environments (#5559). This occurs due to some limitation we have with the VS Code terminals and conda. Here is a workaround for this:

  1. Turn off auto activation. To do this, disable these two settings, ideally only for the project you are working on:
    image
  2. Exit VS Code.
  3. Open Anaconda Prompt, navigate to your project.
  4. Activate the environment that you want.
  5. Run code . or code project.code-workspace to launch VS Code.

This will give you an activated environment, and the extension will not have to try and activate every time a terminal is created.

@karthiknadig karthiknadig self-assigned this Oct 12, 2020
@ghost ghost removed the triage-needed Needs assignment to the proper sub-team label Oct 12, 2020
@GilShoshan94
Copy link

GilShoshan94 commented Oct 31, 2020

Hi @karthiknadig, I also work with conda.

I like your solution, it also fixes issue for me when I try to use pytest inside vscode in a conda env (doesn't work otherwise, crashes at the import of numpy...)

Is it possible to add a setting to vscode that would launch vscode inside an activated environment ?

Sorry if it sound confusing.
I mean a setting that would replace my need to launch vscode from an actived conda env in a terminal with code

@karthiknadig
Copy link
Member

@GilShoshan94 We have plans to improve overall activation and terminal experience. they are tracked here #8907, #4568

@github-actions github-actions bot locked as resolved and limited conversation to collaborators Sep 28, 2021
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
bug Issue identified by VS Code Team member as probable bug
Projects
None yet
Development

No branches or pull requests

3 participants