How to let pyenv to find installed python versions
Asked Answered
B

3

35

I experience a following contradictory problem with pyenv:

$ pyenv global python2.7.10
pyenv: version `python2.7.10' not installed
$ pyenv install 2.7.10
pyenv: /Users/xeli/.pyenv/versions/2.7.10 already exists
continue with installation? (y/N) 

Also:

$ python2.7
pyenv: python2.7: command not found

The `python2.7' command exists in these Python versions:
  2.7.10

The shims are on the PATH as required:

$ echo $PATH
/Users/xeli/.pyenv/shims:/usr/local/bin:/usr/bin:/bin:/usr/sbin:/sbin:/opt/X11/bin

Nothing suspicious in the shims directory:

$ ls ~/.pyenv/shims | grep python2
ipython2
python2
python2-config
python2.6
python2.6-config
python2.7
python2.7-config

In my .profile I have:

export PYENV_ROOT=~/.pyenv
if which pyenv > /dev/null; then eval "$(pyenv init -)"; fi

Therefore pyenv should be initialized at startup.

I cannot figure out how to solve this. Any ideas?

Bootleg answered 1/4, 2016 at 12:48 Comment(0)
B
28

pyenv seems to require explicit .python-version file to be set in the current directory for any other version than the default in .pyenv/version. This is explained in a closed GitHub issue.

The problem is fixed by creating .python-version file. This is done automatically for example by $ pyenv local 2.7.10.

The initial problem therefore is in the poor error message. I created a new issue to fix it.

Bootleg answered 1/4, 2016 at 13:32 Comment(1)
~/.python-version?Emphasize
M
26

Short answer — all you need to do is:

pyenv global 2.7.10

pyenv’s name for the Python 2.7.10 interpreter version is just 2.7.10, not python2.7.10. You can get a list of all your installed versions with:

pyenv versions
Marc answered 12/4, 2016 at 6:50 Comment(0)
P
1

I had a version installed and then later uninstalled it, but the version reference remained in .pyenv/version. Error went away once I manually removed it from there.

Portable answered 3/12, 2021 at 7:44 Comment(0)

© 2022 - 2024 — McMap. All rights reserved.