-
-
Notifications
You must be signed in to change notification settings - Fork 25
pyenv 'command not found' with system python set #141
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
Comments
Can you run with logging turned on?
I'm not a pyenv user so I can only guess it's because |
BTW, what does |
Yeah the pyenv
|
I don't want to add pyenv-specific logic into the Launcher. Does pyenv manipulate your
So would that mean if it's set to |
The other solution for dealing with I realize that doesn't solve your |
I don't think you can solve this without integrating against pyenv, see pypa/virtualenv#2130 that's related. An executable named python can literally point to any python with pyenv. You'd have to duplicate the logic of pyenv shim layer to get it right. |
Long-time pyenv user here, and while it's possible to use pyenv to manage your system python, it's not really built for managing your system-level python. I'd recommend running If you want py to support it, I would treat |
Would this work as the updated entry for the FAQ for bash and zsh? pyenv_version=$(head -n 1 pyenv-version.txt | cut -d "." -f 1,2)
if [ $pyenv_version != 'system' ]; then
export PY_PYTHON=$pyenv_version
fi; |
And for fish: set pyenv_version (head -n 1 pyenv-version.txt | cut -d "." -f 1,2)
if test "$pyenv_version" != "system"
set -xg PY_PYTHON $pyenv_version
end |
Otherwise we can add a disclaimer to the FAQ entry to say |
Perhaps my original intent for this bug report has lost it's way. I was interested to try out python-launcher but since I happen to have pyenv installed it failed to work. I imagined that this could be a common use-case so reported the bug so that it could be logged, considered and fixed.
I understand the sentiment but if pyenv has been installed it seems unavoidable if launcher is unwittingly picking up the pyenv shims. pyenv global path
An install of pyenv with env vars added to e.g. after pyenv install this is now the
pyenv shimsFrom understanding-shims
This means that we cannot escape handling pyenv with it added to PATH:
No the directory of shims is added to PATH:
Maybe the best-effort here is to check for
I am not sure it makes sense to have that particular FAQ entry for pyenv since it is already going to be overriding the PATH python and launcher should be treating it as the OS python? After considering all of this I can understand if you instead want to say that launcher is not compatible with pyenv 😄 |
I set pyenv to Then when creating a new git project, I always start with running e.g. "pyenv local 3.9.6" which creates a All of the above of course requires me to have previously executed "pyenv install 3.9.6" so this python version gets installed on my system. Given my workflow, I'm wondering how useful the python launcher is to you (me) if you are already using pyenv...? I don't know if this helps, but I figured I'd share my workflow. |
That's still pyenv-specific and so I would rather not do that.
I don't want to go that far as people like @jefftriplett have shown they get use out of the Launcher with pyenv (as has @treyhunner and other folks who helped write that FAQ entry). Maybe they can share how they make them work together?
Then the Launcher isn't necessarily that useful. It still helps with shebangs and using the newest version of Python and using virtual environments automatically. But if you're already using pyenv to accomplish this then you don't need the Launcher (or you can obviously switch over if you want 😉). |
I have gained a bit more understanding after reading the original problem that the FAQ entry was written for. In that scenario Python 3.10 is in the PATH (perhaps not provided by pyenv?) and Launcher is picking that first. Perhaps could be solved by instead of trying to parse a pyenv specific version file (that may or may not exist) we use the pyenv command to get the version from the python it considers current default. My proposal would be to replace the FAQ entry for pyenv with the following:
From my quick testing this solves my issue and original FAQ issue but would like some confirmation Thanks for your patience Brett 😁 |
@cas-- does this last script work for you when you have It seems to work for me, but I don't set |
It works for all combinations however for completeness need to include
* Didn't use print sep arg for python just in-case python2 is being used. The final issue to note is that once env vars are set any changes to pyenv global will not update them until session reload. Could be fixed with alias for |
When using pyenv and global not set (defaulting to system) or global set to `system` the Launcher was unable to determine correct version to use. Fixed by using `pyenv exec` to correctly determine current Python version instead of parsing pyenv config files. Fixes brettcannon#141
I left a comment on the review, but that's not quite the right use of |
Describe the bug
Encountering error running
py
due to pyenv installed and set tosystem
To Reproduce
pyenv
Tried export
PY_PYTHON
as per FAQ but version file does not exist if global not set:So tried creating file with
pyenv global
but that also failed on the special stringsystem
:Expected behaviour
Opens system python 3.8 prompt
Screenshots
System Details (please complete the following information):
The text was updated successfully, but these errors were encountered: