Skip to content

Support pyenv-win on Windows #15304

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
empz opened this issue Feb 3, 2021 · 15 comments
Closed

Support pyenv-win on Windows #15304

empz opened this issue Feb 3, 2021 · 15 comments
Assignees
Labels
area-environments Features relating to handling interpreter environments feature-request Request for new features or functionality info-needed Issue requires more information from poster

Comments

@empz
Copy link

empz commented Feb 3, 2021

Currently, the Python extension seems to rely on the py launcher installed by the official windows installers.

I'm using pyenv-win to manage different python versions on my Windows machine and I wasn't able to make VS Code detect it, even though running python on my terminal worked perfectly. I've even tried setting explicitly the python.defaultInterpreterPath setting but that didn't work either.

So, apart from the feature request. Is there a way to use the Python extension without having the py launcher available on C:\Windows

@empz empz added triage-needed Needs assignment to the proper sub-team feature-request Request for new features or functionality labels Feb 3, 2021
@ghost ghost removed the triage-needed Needs assignment to the proper sub-team label Feb 3, 2021
@karthiknadig karthiknadig added the area-environments Features relating to handling interpreter environments label Feb 3, 2021
@karthiknadig
Copy link
Member

Thank you for the suggestion! We have marked this issue as "needs decision" to make sure we have a conversation about your idea. We plan to leave this feature request open for at least a month to see how many 👍 votes the opening comment gets to help us make our decision.

@vgibilmanno
Copy link

I'd love to have this feature too. Meanwhile I created a separate extension for pyenv-win to have a quick working solution for me. But would be awesome to see this feature work in this package of course. https://github.com/vgibilmanno/vscode-winpyenv

@karthiknadig
Copy link
Member

@vgibilmanno We have a experimental discovery component that supports this. Add this to your user settings to try it out:
image

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

And reload VS Code.

@karthiknadig
Copy link
Member

image

@luabud
Copy link
Member

luabud commented Mar 24, 2021

@empz do you mind checking if Karthik's solution solves the issue for you? thanks!

@luabud luabud added info-needed Issue requires more information from poster and removed needs decision labels Mar 24, 2021
@ghost ghost added the triage-needed Needs assignment to the proper sub-team label Mar 24, 2021
@luabud luabud added triage and removed triage-needed Needs assignment to the proper sub-team labels Mar 24, 2021
@luabud luabud assigned luabud and karthiknadig and unassigned luabud Mar 24, 2021
@vgibilmanno
Copy link

@karthiknadig I tried your solution but it doesn't work for me. In case it matters, I'm using the following version of the extension: v2021.3.680753044

@karthiknadig
Copy link
Member

@vgibilmanno Can you share the contents of Output > Python panel? If you are in the experiment it should show that you are part of that experiment group. We look for pyenv-win in %USERPROFILE%/.pyenv/pyenv-win can you confirm that pyenv-win is installed there?

@vgibilmanno
Copy link

@karthiknadig This is the output:

User belongs to experiment group 'pythonDiscoveryModule'
User belongs to experiment group 'pythonaacf'
User belongs to experiment group 'pythonJoinMailingListVar2'
User belongs to experiment group 'pythonSendEntireLineToREPL'
User belongs to experiment group 'pythonNotDisplayLinterPrompt'
User belongs to experiment group 'ShowExtensionSurveyPrompt - control'
User belongs to experiment group 'CollectLSRequestTiming - control'
Python interpreter path: ~\AppData\Local\Programs\Python\Python36\python.exe
Starting Jedi Python language engine.
> ~\AppData\Local\Programs\Python\Python36\python.exe c:\Users\vgibilmanno\.vscode\extensions\ms-python.python-2021.3.680753044\pythonFiles\pyvsc-run-isolated.py -c "import sys;print(sys.prefix)"
cwd: c:\Users\vgibilmanno\Desktop\temp\art
> ~\AppData\Local\Programs\Python\Python36\python.exe c:\Users\vgibilmanno\.vscode\extensions\ms-python.python-2021.3.680753044\pythonFiles\pyvsc-run-isolated.py -c "import sys;print(sys.prefix)"
cwd: c:\Users\vgibilmanno\Desktop\temp\art
> ~\AppData\Local\Programs\Python\Python36\python.exe c:\Users\vgibilmanno\.vscode\extensions\ms-python.python-2021.3.680753044\pythonFiles\pyvsc-run-isolated.py -c "import sys;print(sys.executable)"
cwd: c:\Users\vgibilmanno\Desktop\temp\art
> ~\AppData\Local\Programs\Python\Python36\python.exe c:\Users\vgibilmanno\.vscode\extensions\ms-python.python-2021.3.680753044\pythonFiles\pyvsc-run-isolated.py -c "import sys;print(sys.executable)"
cwd: c:\Users\vgibilmanno\Desktop\temp\art
> ~\AppData\Local\Programs\Python\Python36\python.exe c:\Users\vgibilmanno\.vscode\extensions\ms-python.python-2021.3.680753044\pythonFiles\pyvsc-run-isolated.py site --user-site
cwd: c:\Users\vgibilmanno\Desktop\temp\art
> ~\AppData\Local\Programs\Python\Python36\python.exe c:\Users\vgibilmanno\.vscode\extensions\ms-python.python-2021.3.680753044\pythonFiles\pyvsc-run-isolated.py site --user-site
cwd: c:\Users\vgibilmanno\Desktop\temp\art
> ~\AppData\Local\Programs\Python\Python36\python.exe c:\Users\vgibilmanno\.vscode\extensions\ms-python.python-2021.3.680753044\pythonFiles\pyvsc-run-isolated.py -c "from distutils.sysconfig import get_python_lib; print(get_python_lib())"
cwd: c:\Users\vgibilmanno\Desktop\temp\art
> ~\AppData\Local\Programs\Python\Python36\python.exe c:\Users\vgibilmanno\.vscode\extensions\ms-python.python-2021.3.680753044\pythonFiles\pyvsc-run-isolated.py -c "from distutils.sysconfig import get_python_lib; print(get_python_lib())"
cwd: c:\Users\vgibilmanno\Desktop\temp\art
> ~\AppData\Local\Programs\Python\Python36\python.exe c:\Users\vgibilmanno\.vscode\extensions\ms-python.python-2021.3.680753044\pythonFiles\pyvsc-run-isolated.py pylint --disable=all --enable=F,unreachable,duplicate-key,unnecessary-semicolon,global-variable-not-assigned,unused-variable,unused-wildcard-import,binary-op-exception,bad-format-string,anomalous-backslash-in-string,bad-open-mode,E0001,E0011,E0012,E0100,E0101,E0102,E0103,E0104,E0105,E0107,E0108,E0110,E0111,E0112,E0113,E0114,E0115,E0116,E0117,E0118,E0202,E0203,E0211,E0213,E0236,E0237,E0238,E0239,E0240,E0241,E0301,E0302,E0303,E0401,E0402,E0601,E0602,E0603,E0604,E0611,E0632,E0633,E0701,E0702,E0703,E0704,E0710,E0711,E0712,E1003,E1101,E1102,E1111,E1120,E1121,E1123,E1124,E1125,E1126,E1127,E1128,E1129,E1130,E1131,E1132,E1133,E1134,E1135,E1136,E1137,E1138,E1139,E1200,E1201,E1205,E1206,E1300,E1301,E1302,E1303,E1304,E1305,E1306,E1310,E1700,E1701 --msg-template='{line},{column},{category},{symbol}:{msg}' --reports=n --output-format=text c:\Users\vgibilmanno\Desktop\temp\art\art.py
cwd: c:\Users\vgibilmanno\Desktop\temp\art
> ~\AppData\Local\Programs\Python\Python36\python.exe c:\Users\vgibilmanno\.vscode\extensions\ms-python.python-2021.3.680753044\pythonFiles\pyvsc-run-isolated.py pylint --disable=all --enable=F,unreachable,duplicate-key,unnecessary-semicolon,global-variable-not-assigned,unused-variable,unused-wildcard-import,binary-op-exception,bad-format-string,anomalous-backslash-in-string,bad-open-mode,E0001,E0011,E0012,E0100,E0101,E0102,E0103,E0104,E0105,E0107,E0108,E0110,E0111,E0112,E0113,E0114,E0115,E0116,E0117,E0118,E0202,E0203,E0211,E0213,E0236,E0237,E0238,E0239,E0240,E0241,E0301,E0302,E0303,E0401,E0402,E0601,E0602,E0603,E0604,E0611,E0632,E0633,E0701,E0702,E0703,E0704,E0710,E0711,E0712,E1003,E1101,E1102,E1111,E1120,E1121,E1123,E1124,E1125,E1126,E1127,E1128,E1129,E1130,E1131,E1132,E1133,E1134,E1135,E1136,E1137,E1138,E1139,E1200,E1201,E1205,E1206,E1300,E1301,E1302,E1303,E1304,E1305,E1306,E1310,E1700,E1701 --msg-template='{line},{column},{category},{symbol}:{msg}' --reports=n --output-format=text c:\Users\vgibilmanno\Desktop\temp\art\art.py
cwd: c:\Users\vgibilmanno\Desktop\temp\art
> ~\AppData\Local\Programs\Python\Python36\python.exe c:\Users\vgibilmanno\.vscode\extensions\ms-python.python-2021.3.680753044\pythonFiles\pyvsc-run-isolated.py c:\Users\vgibilmanno\.vscode\extensions\ms-python.python-2021.3.680753044\pythonFiles\completion.py
> ~\AppData\Local\Programs\Python\Python36\python.exe c:\Users\vgibilmanno\.vscode\extensions\ms-python.python-2021.3.680753044\pythonFiles\pyvsc-run-isolated.py c:\Users\vgibilmanno\.vscode\extensions\ms-python.python-2021.3.680753044\pythonFiles\completion.py
> ~\AppData\Local\Programs\Python\Python36\python.exe c:\Users\vgibilmanno\.vscode\extensions\ms-python.python-2021.3.680753044\pythonFiles\pyvsc-run-isolated.py -c "import pylint"
> ~\AppData\Local\Programs\Python\Python36\python.exe c:\Users\vgibilmanno\.vscode\extensions\ms-python.python-2021.3.680753044\pythonFiles\pyvsc-run-isolated.py -c "import pylint"
> ~\AppData\Local\Programs\Python\Python36\python.exe c:\Users\vgibilmanno\.vscode\extensions\ms-python.python-2021.3.680753044\pythonFiles\pyvsc-run-isolated.py -c "import pylint"
> ~\AppData\Local\Programs\Python\Python36\python.exe c:\Users\vgibilmanno\.vscode\extensions\ms-python.python-2021.3.680753044\pythonFiles\pyvsc-run-isolated.py -c "import pylint"

Linter 'pylint' is not installed. Please install it or select another linter".
Error: Module 'pylint' not installed.
> conda --version

I can confirm, that pyenv-win is installed there
image

@karthiknadig
Copy link
Member

@vgibilmanno Can you check if you have any of the following environment variables set?

  • PYENV
  • PYENV_ROOT

If so what is their value?

@vgibilmanno
Copy link

PYENV: %USERPROFILE%.pyenv\pyenv-win\

PYENV_ROOT was not set. I manually set it to %USERPROFILE%.pyenv\pyenv-win\bin and restarted VS Code but it still doesn't detect pyenv.

@karthiknadig
Copy link
Member

Can you try and set it like this:
image

if %USERPROFILE% does not end with a \ then the path will be wrong. In my case it does not end with a \
image

@vgibilmanno
Copy link

It worked. Though I don't know if setting the PYENV_HOME environment variable fixed it or because removing \ at the end. I tried deleting the PYENV_HOME and setting the \ to the PYENV variable again, but now VS Code always finds the pyenv interpreters (probably caches found locations?)

@karthiknadig
Copy link
Member

@vgibilmanno We do some cashing. Can you share the value of USERPROFILE, and PYENV that you have? On windows we look at PYENV only. I think USERPROFILE did not terminate with a separator. So %USERPROFILE%.pyenv\pyenv-win\ was expanding to something like C:\Users\username.pyenv\pyenv-win\. Probably resetting it with absolute path ensured there was a separator after the user name.

@vgibilmanno
Copy link

vgibilmanno commented Mar 29, 2021

image

That's my current value. It's the same it was when pyenv was detected by the extension

EDIT: I just tried and it's definitely because of the additional \ at the end of the path. Though the \ is there by default when installing pyenv-win

@karthiknadig
Copy link
Member

Closing this since the feature itself is now available under the pythondiscoverymodule experiment.

@github-actions github-actions bot locked as resolved and limited conversation to collaborators Sep 27, 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 feature-request Request for new features or functionality info-needed Issue requires more information from poster
Projects
None yet
Development

No branches or pull requests

4 participants