Skip to content

Can't select Anaconda virtual environment Python 3.10 interpreter #17941

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

Closed
1 task done
duncantop opened this issue Nov 5, 2021 · 10 comments · Fixed by #18128
Closed
1 task done

Can't select Anaconda virtual environment Python 3.10 interpreter #17941

duncantop opened this issue Nov 5, 2021 · 10 comments · Fixed by #18128
Assignees
Labels
area-environments Features relating to handling interpreter environments bug Issue identified by VS Code Team member as probable bug important Issue identified as high-priority verified Verification succeeded
Milestone

Comments

@duncantop
Copy link

VS Code version

1.62.0

Extension version

v2021.11.1422169775

OS type

Windows

OS version

10

Python distribution

Anaconda

Python version

3.10.0

Language server

Pylance

Expected behaviour

I should be able to see and select my py310 anaconda python installation.

Actual behaviour

When selecting a python interpreter, I see my list of non-3.10 environments but only briefly see my py310 environment at the bottom of the list before it disappears. When I have forced the interpreter to my py310 install vscode still asks me to select an interpreter.

Steps to reproduce

No matter how I create a new anaconda environment with python 3.10, the same thing happens. I have tried making new non-3.10 environments and they show up in the interpreter list and are usable. Issue seems exclusive to python 3.10.

Logs

Experiment 'pythonaa' is active
Experiment 'pythonTensorboardExperiment' is active
Experiment 'pythonSurveyNotification' is active
Experiment 'PythonPyTorchProfiler' is active
Experiment 'pythonDeprecatePythonPath' is active
Experiment 'pythonRunFailedTestsButtonDisplayed' is active
Experiment 'pythonRefreshTestsButtonDisplayed' is active
Experiment 'pythonRememberDebugConfig' is active

~\anaconda3\condabin info --json
conda info --json
~\anaconda3\python.exe ~.vscode\extensions\ms-python.python-2021.11.1422169775\pythonFiles\interpreterInfo.py
~\anaconda3\Scripts\conda.exe info --json
~\anaconda3\envs\py310\python.exe ~.vscode\extensions\ms-python.python-2021.11.1422169775\pythonFiles\interpreterInfo.py
\anaconda3\envs\py39\python.exe .vscode\extensions\ms-python.python-2021.11.1422169775\pythonFiles\interpreterInfo.py
"
\anaconda3\Scripts\activate && conda activate base && echo 'e8b39361-0157-4923-80e1-22d70d46dee6' && python c:\Users\dunca.vscode\extensions\ms-python.python-2021.11.1422169775\pythonFiles\printEnvVariables.py"
"
\anaconda3\Scripts\activate && conda activate base && echo 'e8b39361-0157-4923-80e1-22d70d46dee6' && python c:\Users\dunca.vscode\extensions\ms-python.python-2021.11.1422169775\pythonFiles\printEnvVariables.py"
~\anaconda3\envs\py397\python.exe ~.vscode\extensions\ms-python.python-2021.11.1422169775\pythonFiles\interpreterInfo.py
python -c "import sys;print(sys.executable)"
python -c "import sys;print(sys.executable)"
python -c "import sys;print(sys.executable)"
python -c "import sys;print(sys.executable)"
python -c "import sys;print(sys.executable)"
python -c "import sys;print(sys.executable)"
Starting Pylance language server.
python -c "import sys;print(sys.executable)"
Error 2021-11-05 13:01:19: Diagnostic Code: InvalidPythonInterpreterDiagnostic, Message: No Python interpreter is selected. You need to select a Python interpreter to enable features such as IntelliSense, linting, and debugging.
Diagnostic Code: InvalidPythonInterpreterDiagnostic, Message: No Python interpreter is selected. You need to select a Python interpreter to enable features such as IntelliSense, linting, and debugging.
python -c "import sys;print(sys.executable)"
python -c "import sys;print(sys.executable)"
python -c "import sys;print(sys.executable)"

Code of Conduct

  • I agree to follow this project's Code of Conduct
@duncantop duncantop added bug Issue identified by VS Code Team member as probable bug triage-needed Needs assignment to the proper sub-team labels Nov 5, 2021
@karthiknadig
Copy link
Member

@duncantop what happens when you run from a command prompt outside of vscode.

~\anaconda3\envs\py310\python.exe ~.vscode\extensions\ms-python.python-2021.11.1422169775\pythonFiles\interpreterInfo.py

@duncantop
Copy link
Author

duncantop commented Nov 6, 2021

(base) C:\Users\dunca>~\anaconda3\envs\py310\python.exe ~.vscode\extensions\ms-python.python-2021.11.1422169775\pythonFiles\interpreterInfo.py
The system cannot find the path specified.

If I type out the tildes:

(base) C:\Users\dunca>c:\users\dunca\anaconda3\envs\py310\python.exe c:\users\dunca\.vscode\extensions\ms-python.python-2021.11.1422169775\pythonFiles\interpreterInfo.py
{"versionInfo": [3, 10, 0, "final", 0], "sysPrefix": "c:\\users\\dunca\\anaconda3\\envs\\py310", "sysVersion": "3.10.0 | packaged by conda-forge | (default, Oct  7 2021, 06:17:52) [MSC v.1916 64 bit (AMD64)]", "is64Bit": true}

@karthiknadig karthiknadig self-assigned this Nov 8, 2021
@karthiknadig karthiknadig added area-environments Features relating to handling interpreter environments triage and removed triage-needed Needs assignment to the proper sub-team labels Nov 8, 2021
@vadimkara
Copy link

I have same problem

@Francois-Bergeron
Copy link

Same issue here, even when setting the 3.10 conda environment as default interpreter.
The 3.10 environment is working fine on other IDEs, and other environments (below 3.10) are working perfectly in VSCode.

@kochuyt
Copy link

kochuyt commented Nov 30, 2021

On Win10, using miniconda and have the same issue with 3.10 not showing up
(pre 3.10 versions show up as expected)

@karthiknadig
Copy link
Member

This is strange, running anything with conda python 3.10 seems to be not working. But 3.9 it does return what we expect.

> conda create -p .venv python=3.10
> .venv\\python.exe -c "import sys;print(sys.executable)"

> conda create -p .venv2 python=3.9
> .venv2\python.exe -c "import sys;print(sys.executable)" 
C:\GIT\repro\conda1\.venv2\python.exe

The reason this is not working is because we are not able to get any info from the python.exe. when we run the script below it is not returning anything with conda python 3.10.

> .venv\python.exe "C:\Users\Karthik Nadig\.vscode\extensions\ms-python.python-2021.11.1422169775\pythonFiles\interpreterInfo.py"

but it does with 3.9:

> .venv2\python.exe "C:\Users\Karthik Nadig\.vscode\extensions\ms-python.python-2021.11.1422169775\pythonFiles\interpreterInfo.py"
{"versionInfo": [3, 9, 7, "final", 0], "sysPrefix": "C:\\GIT\\repro\\conda1\\.venv2", "sysVersion": "3.9.7 (default, Sep 16 2021, 16:59:28) [MSC v.1916 64 bit (AMD64)]", "is64Bit": true}

@brettcannon brettcannon added this to the January 2022 milestone Nov 30, 2021
@brettcannon brettcannon added needs PR important Issue identified as high-priority and removed triage labels Nov 30, 2021
@brettcannon
Copy link
Member

brettcannon commented Nov 30, 2021

We have diagnosed the issue: Python 3.10 builds from conda require all commands be run through an activated environment (otherwise it raises an error about not being able to find zlib.dll). We were avoiding this for performance reasons, but it looks like we can no longer do so.

To work around this until we can get it properly fixed you can launch VS Code from an activated conda environment in the terminal (which also deals with any race condition issues in the terminal itself as well; something we are planning to fix with #11039 ).

Unfortunately fixing this is going to require two parts due to the fact that we now have to use conda run everywhere where a conda environment may be involved:

  1. Fix this issue
  2. Finish Support Conda run #17973 (which we are in the process of doing)

@duncantop
Copy link
Author

Thanks for looking into this, supplying a work around, and describing the path forward for this issue.

@kochuyt
Copy link

kochuyt commented Nov 30, 2021

Some additional info (for what it is worth), this does not happen with all conda builds of python3.10...

When creating a new conda env for py3.10 the "naive way"
[meaning not specifying the channel so conda create --name py3ten python=3.10]
the py3ten environment & interpreter does not show up in vscode

However, when creating a conda env "specifying conda-forge channel"
[so conda create --name py3ten_cf --channel conda-forge python=3.10]
Lo and behold, the py3ten_cf environment & interpreter does show up in vscode

When doing a conda list python in both envs, following differences are seen

(py3ten) PS C:\Users\******> conda list python
# packages in environment at C:\Users\******\Miniconda3\envs\py3ten:
#
# Name                    Version                   Build  Channel
python                    3.10.0               h96c0403_3

vs

(py3ten_cf) PS C:\Users\******> conda list python
# packages in environment at C:\Users\******\Miniconda3\envs\py3ten_cf:
#
# Name                    Version                   Build  Channel
python                    3.10.0          hcf16a7b_3_cpython    conda-forge
python_abi                3.10                    2_cp310    conda-forge

Don't know if this helps to narrow down the issue / root-cause but it would trigger me to reach out to the anaconda guys to try and understand why this difference is seen

@kochuyt
Copy link

kochuyt commented Nov 30, 2021

Some more info.... the python3.10 installed by explicitely specifying conda-forge seems to be more recent...

(py3ten_cf) PS C:\Users\******> conda activate py3ten
(py3ten) PS C:\Users\******> python
Python 3.10.0 | packaged by conda-forge | (default, Nov 10 2021, 13:20:59) [MSC v.1916 64 bit (AMD64)] on win32
Type "help", "copyright", "credits" or "license" for more information.
>>>

vs

(base) PS C:\Users\******> conda activate py3ten_cf
(py3ten_cf) PS C:\Users\******> python
Python 3.10.0 | packaged by conda-forge | (default, Nov 20 2021, 02:18:13) [MSC v.1916 64 bit (AMD64)] on win32
Type "help", "copyright", "credits" or "license" for more information.
>>>

@github-actions github-actions bot locked as resolved and limited conversation to collaborators Jan 8, 2022
@karthiknadig karthiknadig added the verified Verification succeeded label Jan 24, 2022
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
area-environments Features relating to handling interpreter environments bug Issue identified by VS Code Team member as probable bug important Issue identified as high-priority verified Verification succeeded
Projects
None yet
Development

Successfully merging a pull request may close this issue.

7 participants