pyenv / pyenv

Simple Python version management

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

"pyenv: python3.11: command not found" despite having selected a global version

charles-cooper opened this issue · comments

i have a fresh install of pyenv 2.3.36 on ubuntu 22.04. i am able to install python versions, and set the global version. however, when i try to run a shim, it fails with command not found. here's an example:

$ python3.11  # same result running: `.pyenv/shims/python3.11`
pyenv: python3.11: command not found

The `python3.11' command exists in these Python versions:
  3.11.8

Note: See 'pyenv help global' for tips on allowing both
      python2 and python3 to be found.

apologies if i am using it incorrectly, but i have been finding the behavior confusing. i debugged to some discrepancy between pyenv whence and pyenv which -- pyenv whence python3.11 works fine:

$ pyenv whence --path python3.11
/home/ubuntu/.pyenv/versions/3.11.8/bin/python3.11

however, pyenv which appears to fail:

$ pyenv which python3.11
pyenv: python3.11: command not found

The `python3.11' command exists in these Python versions:
  3.11.8

Note: See 'pyenv help global' for tips on allowing both
      python2 and python3 to be found.

here is the output with --debug https://gist.github.com/charles-cooper/3f39478a546e4db94b4910f4d6894949.

and here is my bash version:

$ bash --version
GNU bash, version 5.1.16(1)-release (x86_64-pc-linux-gnu)

any help is much appreciated!

You have selected 3.12 as the global version, not 3.11:

+(/home/ubuntu/.pyenv/libexec/pyenv-version-file-read:6): VERSION_FILE=/home/ubuntu/.pyenv/version
<...>
+(/home/ubuntu/.pyenv/libexec/pyenv-version-file-read:28): read -n 1024 -r version _
+(/home/ubuntu/.pyenv/libexec/pyenv-version-file-read:29): [[ -z 3.12 ]]
<...>

Note that if you need multiple versions available, you can select them all:

pyenv global 3.12 3.11

They'll be searched for the executable you're trying to run in the specified order.

Note that if you need multiple versions available, you can select them all:

pyenv global 3.12 3.11

They'll be searched for the executable you're trying to run in the specified order.

aha, thanks. it would be helpful to document this! (also maybe the default for pyenv install should be to install into global.)

aha, thanks. it would be helpful to document this! (also maybe the default for pyenv install should be to install into global.)

It is documented: https://github.com/pyenv/pyenv/blob/master/COMMANDS.md#pyenv-global-advanced

It is documented: https://github.com/pyenv/pyenv/blob/master/COMMANDS.md#pyenv-global-advanced

i saw that, but it was not apparent that this step is required in order for the shims to work. maybe a debugging / FAQ type item could be added for those who run into the same issue?