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

Extension doesn't activate conda environment #6918

Closed
cristi-neagu opened this issue Aug 9, 2019 · 7 comments
Closed

Extension doesn't activate conda environment #6918

cristi-neagu opened this issue Aug 9, 2019 · 7 comments
Labels
info-needed Issue requires more information from poster

Comments

@cristi-neagu
Copy link

cristi-neagu commented Aug 9, 2019

Hello,

It used to be the case that when i ran a script in debug within a conda environment, the first time it would fail with the error ImportError: DLL load failed: The specified module could not be found. Right after the debugger would end, the console would run conda activate to activate the environment, and running the script again would function correctly.

But that isn't happening any longer. A few days ago i updated conda (using the prompt), and something went wrong and Anaconda shortcuts disappeared from the Start Menu. I reinstalled conda in the exact same location, and it is working fine. Jupyter Notebook launches correctly, runs ok, no problems. But now VS Code doesn't activate the environment any longer. It does see the environments and i can select them. It does seem to use the selected environment, as it complains about pylint not being installed if i switch to an environment with no pylint.

I tried adding the conda folder to the path. This actually worked for 1 session of using VS Code, and now it doesn't work any longer, with me not changing absolutely anything. I tried initializing cmd.exe for use with conda, so now i can type conda activate in the Python debug terminal and it does activate the terminal and the script can run. But VS Code is still not doing it automatically.

Also, when i installed conda, i did select the option that makes it visible to VS Code. I forget the actual wording, but it was on the same screen as the "add to path" option.

At this point i don't even know if this is a conda issue, a VS Code issue, or a Python extension issue. Any ideas are welcome.

Thank you.

@cristi-neagu cristi-neagu added the triage-needed Needs assignment to the proper sub-team label Aug 9, 2019
@DonJayamanne
Copy link

Thanks for reporting this issue.
However to help you we need more information, please could you take the Time to fill in the issue template.

@brettcannon brettcannon added the info-needed Issue requires more information from poster label Aug 12, 2019
@ghost ghost removed the triage-needed Needs assignment to the proper sub-team label Aug 12, 2019
@Wenzil
Copy link

Wenzil commented Aug 19, 2019

I have the same (or a very similar) issue.

Environment data

  • VS Code version: 1.37.1
  • Extension version (available under the Extensions sidebar): 2019.8.30787
  • OS and version: macOS Mojave 10.14.6
  • Python version (& distribution if applicable, e.g. Anaconda): Anaconda3
  • Type of virtual environment used (N/A | venv | virtualenv | conda | ...): conda
  • Relevant/affected Python packages and their versions: the issue is package agnostic
  • Jedi or Language Server? (i.e. what is "python.jediEnabled" set to; more info How to update the language server to the latest stable version #3977): true

Expected behaviour

VS Code picks up the Conda environment specified in my python.pythonPath folder setting when starting the Python Interactive session, e.g. /Users/<redacted>/anaconda3/envs/<my_env>/bin/python

Actual behaviour

VS Code only picks up the base Conda environment:

Jupyter Server URI: http://localhost:8889/?token=<redacted>
Python version:
3.7.3 (default, Mar 27 2019, 16:54:48) \n[Clang 4.0.1 (tags/RELEASE_401/final)]
(6, 0, 0)
/Users/<redacted>/anaconda3/bin/python

Steps to reproduce:

  1. Create a multi-root workspace
  2. Create a basic my_env conda environment (from an external terminal shell)
conda create -n my_env python pylint pyface
  1. With the Python: Select Interpreter command, for some folder in the multi-root workspace, select the my_env conda environment
  2. Create a single-cell .py file in the folder
#%%
import pyface
  1. Within the file, click on Run Cell to start a Python Interactive session
  2. Notice the environment being picked up is not matching the one selected in step 3.

Logs

Output for cell [1] in the Python Interactive window

---------------------------------------------------------------------------
ModuleNotFoundError                       Traceback (most recent call last)
 in 
----> 1 import pyface

ModuleNotFoundError: No module named 'pyface'

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

> conda env list
> conda info --json
> ~/anaconda3/bin/python -m jupyter notebook --version
> ~/anaconda3/bin/python -m jupyter kernelspec --version
> ~/anaconda3/bin/python -m jupyter kernelspec list
> ~/anaconda3/bin/python -m jupyter kernelspec list
> ~/anaconda3/bin/python -m jupyter notebook --no-browser --notebook-dir=/var/folders/q5/pspsf7q94qlbhdn41jqr6_080000gn/T/da9e7816-c209-412e-bfa5-86fa1de7eab3 --config=/var/folders/q5/pspsf7q94qlbhdn41jqr6_080000gn/T/da9e7816-c209-412e-bfa5-86fa1de7eab3/jupyter_notebook_config.py --NotebookApp.iopub_data_rate_limit=10000000000.0
> ~/anaconda3/bin/python ~/.vscode/extensions/ms-python.python-2019.8.30787/pythonFiles/datascience/getServerInfo.py
> ~/anaconda3/bin/python ~/.vscode/extensions/ms-python.python-2019.8.30787/pythonFiles/datascience/getServerInfo.py
> ~/anaconda3/bin/python -m ipykernel --version

@ericsnowcurrently ericsnowcurrently removed the info-needed Issue requires more information from poster label Aug 21, 2019
@Wenzil
Copy link

Wenzil commented Aug 21, 2019

I found https://github.com/microsoft/vscode-python/issues/3123 to be the culprit. My workaround is to move up my project to be the first folder in my multi-root workspace

@ericsnowcurrently
Copy link
Member

@cristi-neagu, does that workaround help you?

@ericsnowcurrently ericsnowcurrently removed their assignment Aug 22, 2019
@ericsnowcurrently ericsnowcurrently added triage-needed Needs assignment to the proper sub-team data science and removed triage labels Aug 22, 2019
@ghost ghost removed the triage-needed Needs assignment to the proper sub-team label Aug 22, 2019
@cristi-neagu
Copy link
Author

Hello,

I apologise for not responding to this earlier. Limited time and all that. I shall respond tomorrow with the requested template.

@ericsnowcurrently Unfortunately no, since it's not a multi-root workspace. It's just one folder. Like i said in my initial post, i don't think this is something caused by VS Code or by the Python extension. Something broke somewhere in my setup, it's just that i don't even know where to start. In any case, i shall post that template tomorrow.

Thank you.

@greazer greazer added the info-needed Issue requires more information from poster label Aug 29, 2019
@ronglums
Copy link

Looks like the original issues isn't data science specific. Removing the label.

@luabud luabud added triage-needed Needs assignment to the proper sub-team and removed triage labels Oct 9, 2019
@kimadeline
Copy link

Duplicate of #7696

@kimadeline kimadeline marked this as a duplicate of #7696 Oct 10, 2019
@ghost ghost removed the triage-needed Needs assignment to the proper sub-team label Oct 10, 2019
@lock lock bot locked as resolved and limited conversation to collaborators Oct 17, 2019
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
info-needed Issue requires more information from poster
Projects
None yet
Development

No branches or pull requests

9 participants