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

Select interpreter popup does not shown any system, pyenv or virtualenv choice. #15439

Closed
erongd opened this issue Feb 18, 2021 · 31 comments
Closed
Assignees
Labels
area-environments Features relating to handling interpreter environments bug Issue identified by VS Code Team member as probable bug

Comments

@erongd
Copy link

erongd commented Feb 18, 2021

Environment data

  • VS Code version: 1.53.2
  • Extension version (available under the Extensions sidebar): v2021.2.576481509
  • OS and version: OSX Catalina 10.15.7
  • Python version (& distribution if applicable, e.g. Anaconda): 3.8.7
  • Type of virtual environment used (N/A | venv | virtualenv | conda | ...): virtualenv
  • 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: Microsoft

[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

When click on select interpreter, the popup should shown all installed python interpreter including system, brew, pyenv and also virtualenv created under pyenv.

Actual behaviour

The select interpreter popup only shown the one interpreter under "/usr/bin/python3", no other interpreters shown like it use to be. However if manually select the desired interpreter/virtualenv through the system dialog box, everything else in python development seems to work just fine.

The extension output the following in the output window complaining of not able to resolve symbolic link, even though all those symbolic link are valid and create by default installation methods include system, brew or pyenv.

Error 2021-02-17 22:56:52: Failed to resolve symbolic link: [Error: ENOENT: no such file or directory, lstat '../../System/Library/Frameworks/Python.framework/Versions/2.7/lib/python2.7'] {
errno: -2,
code: 'ENOENT',
syscall: 'lstat',
path: '../../System/Library/Frameworks/Python.framework/Versions/2.7/lib/python2.7'
}

Error 2021-02-17 22:56:52: Failed to resolve symbolic link: [Error: ENOENT: no such file or directory, lstat '../Cellar/[email protected]/3.9.1_8/bin/python3'] {
errno: -2,
code: 'ENOENT',
syscall: 'lstat',
path: '../Cellar/[email protected]/3.9.1_8/bin/python3'
}
Error 2021-02-17 22:56:52: Failed to resolve symbolic link: [Error: ENOENT: no such file or directory, lstat '../Cellar/[email protected]/3.9.1_8/bin/python3.9'] {
errno: -2,
code: 'ENOENT',
syscall: 'lstat',
path: '../Cellar/[email protected]/3.9.1_8/bin/python3.9'
}

BTW, I tested the same setup on linux or windows, it works fine.

@erongd erongd added triage-needed Needs assignment to the proper sub-team bug Issue identified by VS Code Team member as probable bug labels Feb 18, 2021
@InterelaySolutions
Copy link

InterelaySolutions commented Feb 18, 2021

Can also confirm this is happening to us. Rolling back to the previous version of the python extension fixes it for now.

@danieldorosz
Copy link

+1. Have rolled back for now.

@marhoy
Copy link

marhoy commented Feb 18, 2021

+1 For me as well. The "Python: Select Interpreter" dialog does not list any of the pyenv virtualenv environments.
Downgrading to version v2021.1.502429796 solves the problem.

@karthiknadig
Copy link
Member

Have you manually opted into experiments? Check for this setting "python.experiments.optInto" = ["All"]. We have a new discovery mechanism, and it might be failing. You can opt into specific experiments if you need that. If you are NOT opted in any experiment let us know, there might be some interference going on with the new discovery module and the old one.

@danieldorosz
Copy link

danieldorosz commented Feb 18, 2021 via email

@karthiknadig
Copy link
Member

@braineruption Can you try this and see if it helps? "python.experiments.optInto": ["pythonDiscoveryModule"]

@karthiknadig karthiknadig self-assigned this Feb 18, 2021
@karthiknadig karthiknadig added area-environments Features relating to handling interpreter environments triage labels Feb 18, 2021
@ghost ghost removed the triage-needed Needs assignment to the proper sub-team label Feb 18, 2021
@albireox
Copy link

I don't see any difference between having

"python.experiments.enabled": true,
"python.experiments.optInto": ["pythonDiscoveryModule"]

or not.

@karthiknadig
Copy link
Member

@albireox Can you share the paths to the interpreters that it is failing to detect? Also, can you share PYENV specific environment variable values?

@albireox
Copy link

It seems to be failing to detect all the pyenv virtualenvs from installations that are not conda. Apparently it finds the pyenv installations and venvs from conda:

Screen Shot 2021-02-18 at 12 23 48

but not others such as ~/.pyenv/versions/3.9.1/bin/python ~/.pyenv/versions/flicamera/bin/python. These are my pyenv versions:

  system
  2.7.13
  2.7.17
  2.7.18
  2.7.9
  3.10.0a5
  3.7.6
  3.8.3
  3.8.3/envs/sdsstools
  3.8.5
  3.8.6
  3.8.6/envs/archon-38
  3.9.0
  3.9.1
  3.9.1/envs/archon
  3.9.1/envs/basecam
  3.9.1/envs/cherno
  3.9.1/envs/datamodel
  3.9.1/envs/flicamera
  3.9.1/envs/jaeger
  3.9.1/envs/roboscheduler
  3.9.1/envs/sdssdb
  3.9.1/envs/tree
  3.9.1/envs/tron
  STUI
  STUI2
  archon
  archon-38
  basecam
  cerebro
  cherno
  chernosim
  clu
  coordio
  datamodel
  default
  drift
* flicamera (set by /Users/albireo/Documents/Code/sdss5/flicamera/.python-version)
  fliswarm
  fps_monitor
  jaeger
  mangadesign
  miniconda3-latest
  miniconda3-latest/envs/3.9.0
  miniconda3-latest/envs/STUI
  miniconda3-latest/envs/STUI2
  miniconda3-latest/envs/cerebro
  miniconda3-latest/envs/chernosim
  miniconda3-latest/envs/clu
  miniconda3-latest/envs/coordio
  miniconda3-latest/envs/default
  miniconda3-latest/envs/drift
  miniconda3-latest/envs/fliswarm
  miniconda3-latest/envs/fps_monitor
  miniconda3-latest/envs/mangadesign
  miniconda3-latest/envs/pydl
  miniconda3-latest/envs/target_selection
  pydl
  roboscheduler
  sdssdb
  sdsstools
  target_selection
  tree
  tron

And the environment variables

Screen Shot 2021-02-18 at 12 26 46

My system also has Python installations from homebrew, but I don't use them for development.

@karthiknadig
Copy link
Member

karthiknadig commented Feb 18, 2021

@albireox thanks for details. I am able to repro the issue. Can you share the output of ls -la from ~./.pyenv/versions?
I think the extension is skipping the ones that are symlinks under that directory.

@albireox
Copy link

albireoproˇalbireo ~/.p/versions [master] » ls                                                    (3.9.1)
total 0
drwxr-xr-x  8 albireo 256 Aug 13  2020 2.7.13/
drwxr-xr-x  8 albireo 256 Nov 25 14:02 2.7.17/
drwxr-xr-x  9 albireo 288 Jun  3  2020 2.7.18/
drwxr-xr-x  9 albireo 288 Jun  3  2020 2.7.9/
drwxr-xr-x  8 albireo 256 Feb 12 09:13 3.10.0a5/
drwxr-xr-x  9 albireo 288 Jul 18  2020 3.7.6/
drwxr-xr-x  9 albireo 288 May 22  2020 3.8.3/
drwxr-xr-x  8 albireo 256 Sep 24 13:52 3.8.5/
drwxr-xr-x  9 albireo 288 Oct 26 23:39 3.8.6/
lrwxr-xr-x  1 albireo  59 Nov 19 19:22 3.9.0 -> /Users/albireo/.pyenv/versions/miniconda3-latest/envs/3.9.0/
drwxr-xr-x  9 albireo 288 Dec 11 12:53 3.9.1/
lrwxr-xr-x  1 albireo  58 Sep 25 17:18 STUI -> /Users/albireo/.pyenv/versions/miniconda3-latest/envs/STUI/
lrwxr-xr-x  1 albireo  59 Sep 25 21:48 STUI2 -> /Users/albireo/.pyenv/versions/miniconda3-latest/envs/STUI2/
lrwxr-xr-x  1 albireo  48 Jan 18 02:24 archon -> /Users/albireo/.pyenv/versions/3.9.1/envs/archon/
lrwxr-xr-x  1 albireo  51 Jan 22 13:51 archon-38 -> /Users/albireo/.pyenv/versions/3.8.6/envs/archon-38/
lrwxr-xr-x  1 albireo  49 Feb 10 18:46 basecam -> /Users/albireo/.pyenv/versions/3.9.1/envs/basecam/
lrwxr-xr-x  1 albireo  61 Aug 19  2020 cerebro -> /Users/albireo/.pyenv/versions/miniconda3-latest/envs/cerebro/
lrwxr-xr-x  1 albireo  48 Jan 31 12:08 cherno -> /Users/albireo/.pyenv/versions/3.9.1/envs/cherno/
lrwxr-xr-x  1 albireo  63 Sep 16 13:00 chernosim -> /Users/albireo/.pyenv/versions/miniconda3-latest/envs/chernosim/
lrwxr-xr-x  1 albireo  57 Aug 19  2020 clu -> /Users/albireo/.pyenv/versions/miniconda3-latest/envs/clu/
lrwxr-xr-x  1 albireo  61 Aug 14  2020 coordio -> /Users/albireo/.pyenv/versions/miniconda3-latest/envs/coordio/
lrwxr-xr-x  1 albireo  51 Jan 31 15:09 datamodel -> /Users/albireo/.pyenv/versions/3.9.1/envs/datamodel/
lrwxr-xr-x  1 albireo  61 Aug 14  2020 default -> /Users/albireo/.pyenv/versions/miniconda3-latest/envs/default/
lrwxr-xr-x  1 albireo  59 Aug 19  2020 drift -> /Users/albireo/.pyenv/versions/miniconda3-latest/envs/drift/
lrwxr-xr-x  1 albireo  51 Dec 13 09:33 flicamera -> /Users/albireo/.pyenv/versions/3.9.1/envs/flicamera/
lrwxr-xr-x  1 albireo  62 Nov 19 19:32 fliswarm -> /Users/albireo/.pyenv/versions/miniconda3-latest/envs/fliswarm/
lrwxr-xr-x  1 albireo  65 Aug 19  2020 fps_monitor -> /Users/albireo/.pyenv/versions/miniconda3-latest/envs/fps_monitor/
lrwxr-xr-x  1 albireo  48 Dec 11 12:54 jaeger -> /Users/albireo/.pyenv/versions/3.9.1/envs/jaeger/
lrwxr-xr-x  1 albireo  65 Sep 16 14:44 mangadesign -> /Users/albireo/.pyenv/versions/miniconda3-latest/envs/mangadesign/
drwxr-xr-x 15 albireo 480 Nov 21 20:59 miniconda3-latest/
lrwxr-xr-x  1 albireo  58 Aug 25 11:02 pydl -> /Users/albireo/.pyenv/versions/miniconda3-latest/envs/pydl/
lrwxr-xr-x  1 albireo  55 Jan 19 14:03 roboscheduler -> /Users/albireo/.pyenv/versions/3.9.1/envs/roboscheduler/
lrwxr-xr-x  1 albireo  48 Feb  1 22:49 sdssdb -> /Users/albireo/.pyenv/versions/3.9.1/envs/sdssdb/
lrwxr-xr-x  1 albireo  51 Jun 24  2020 sdsstools -> /Users/albireo/.pyenv/versions/3.8.3/envs/sdsstools/
lrwxr-xr-x  1 albireo  70 Aug 17  2020 target_selection -> /Users/albireo/.pyenv/versions/miniconda3-latest/envs/target_selection/
lrwxr-xr-x  1 albireo  46 Jan 31 15:06 tree -> /Users/albireo/.pyenv/versions/3.9.1/envs/tree/
lrwxr-xr-x  1 albireo  46 Dec 27 19:22 tron -> /Users/albireo/.pyenv/versions/3.9.1/envs/tron/

@danieldorosz
Copy link

I tried the pythonDiscoveryModule but that made no difference. What's missing for me are the Homebrew installed pythons and the pyenv virtual envs, i.e. all the installations that are sym-linked.

@marhoy
Copy link

marhoy commented Feb 19, 2021

@albireox thanks for details. I am able to repro the issue. Can you share the output of ls -la from ~./.pyenv/versions?
I think the extension is skipping the ones that are symlinks under that directory.

@karthiknadig: Yes, that's the problem I'm seing. The "base" pyenv-versions show up, but not the virtual environments based on the base versions. And they are all symlinks:

╰─ /bin/ls -1F ~/.pyenv/versions
3.5.3/
3.8.5/
3.8.6/
3.8.7/
3.9.0/
3.9.1/
codejam@
cookiecutter@
cookie-example@
cosmos_dump@
dateml@
datesim-fb-explorer@
datesim-predict@
IHS-demo@
IHS-engine@
jupyter@
meteogram@
mlfactory@
pscdetentions@
riskbasedverification@
visutils@

@brybalicious
Copy link

I mentioned in Issue #15457 that I am having the opposite problem on Windows 10 with WSL 2, using visual studio code insiders.

I finally managed to set up pyenv so that pyenv shims come first in the path, and added a symlink so that python in usr/bin/python points to usr/bin/python3 and thus system python is available when running pyenv versions.

Now, however, in visual studio code insiders, the system python doesn't show up as an available interpreter (which I would imagine should be found automatically in usr/bin/python. I can add it manually though, but it doesn't persist beyond one session. Should I be making another issue for this?

@Aiden-Jeon
Copy link

I have this issue too.
It seems like to be not detecting symbolic python versions in .pyenv/versions
This is my ls result in .pyenv/versions

> ls
3.7.9 3.8.6 kube  upbit

And this is python interpreter in vscode.
image

@karthiknadig
Copy link
Member

@brybalicious That sounds like a different issue. Please file a separate bug.

@karthiknadig
Copy link
Member

@Aiden-Jeon Can you confirm that you don't have any experiments that you have opted into? check for python.exeperiments in your settings.

@tyler-8
Copy link

tyler-8 commented Feb 19, 2021

If you're having the issue described in the OP, please add the thumbs-up (👍 ) reaction to the OP so this issue has more visibility.

@robsgreen
Copy link

robsgreen commented Feb 19, 2021

I'm having the same issue. It seems that the discovery mechanism isn't able to follow symlinks any more.

A workaround that I've found is to use "Enter Interpreter Path..." and enter the full path to the env's binary without going through the symlink. For example, to use the venv my-env:

$ ls -l ~/.pyenv/versions/my-env
lrwxr-xr-x  1 rob  staff  42 Feb 19 11:02 ~/.pyenv/versions/my-env -> ~/.pyenv/versions/3.8.6/envs/my-env

In the "Enter Interpreter Path..." input, use:
~/.pyenv/versions/3.8.6/envs/my-env/bin/python

@albireox
Copy link

This seems fixed to me in the latest vscode-python insiders either with "python.experiments.optInto": ["pythonDiscoveryModule"] or without it, although I'm seeing some differences in the names of the venvs depending on whether the experiment is on or not.

@karthiknadig
Copy link
Member

We just pushed a point release with a fix for this. Please try and let us know.

@albireox
Copy link

Point release also works for me.

@erongd
Copy link
Author

erongd commented Feb 19, 2021

Point release also works for me too.

@robsgreen
Copy link

Works for me, thanks!

@karrtikr
Copy link

Glad it worked, closing this now. If it still happens let us know and we'll reopen the issue.

@LeoAzLiu
Copy link

Do not work for me. 😢
I use pyenv-win on window 10. The "pyenv" function never worked for me but the version v2021.2.576481509. I was exciting when I found it worked. Now it gone again. Is anything I need to config with my scene(pyenv-win)? Thanks!

@danieldorosz
Copy link

Yup, worked for me too. Thanks for the quick turnaround.

@karthiknadig
Copy link
Member

@LeoAzLiu pyenv-win is detected in the new experimental version of the discovery code. You can get that by opting into it, ad this to your user settings:

"python.experiments.enabled": true,
"python.experiments.optInto": ["pythonDiscoveryModule"]

image

@LeoAzLiu
Copy link

@karthiknadig Thanks a lot. It works great! By the way I think the pyenv-win is supported. Why the issue #15304 is still marked as "needs decision"? It is just a little confuse. But it is OK. It works! Thanks again! 👍

@ulises-castro
Copy link

ulises-castro commented Mar 31, 2021

For my case, What it was worked:

"python.defaultInterpreterPath": "/home/{USER}/.pyenv/versions/{PROJECT}/bin/python",
"python.experiments.enabled": true,
"python.experiments.optInto": [
    "pythonDiscoveryModule"
]

@ravigomez
Copy link

For my case, What it was worked:

"python.defaultInterpreterPath": "/home/{USER}/.pyenv/versions/{PROJECT}/bin/python",
"python.experiments.enabled": true,
"python.experiments.optInto": [
    "pythonDiscoveryModule"
]

For me it worked on windows. I used "python.defaultInterpreterPath": "%USERPROFILE%.pyenv\pyenv-win\bin"

@github-actions github-actions bot locked as resolved and limited conversation to collaborators Sep 15, 2021
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
Projects
None yet
Development

No branches or pull requests