I am trying to get pyenv up and running (Mac OS X), so I can use tox/detox to test code vs. multiple python environments. I was able to install multiple python3 versions, and then I used pyenv global
on all the versions. After doing that, pyenv versions
returns this list:
system
* 3.2.6 (set by /Users/Workspace/.pyenv/version)
3.3.6
3.4.6
3.5.3
3.6.1
However, only 3.4 and 3.5 are recognized (along with 2.7.8, which I believe is 'system'):
Geoffreys-MBP:pydnmr-tox Workspace$ python --version
Python 2.7.8
Geoffreys-MBP:pydnmr-tox Workspace$ python3.2 --version
-bash: python3.2: command not found
Geoffreys-MBP:pydnmr-tox Workspace$ python3.3 --version
-bash: python3.3: command not found
Geoffreys-MBP:pydnmr-tox Workspace$ python3.4 --version
Python 3.4.3
Geoffreys-MBP:pydnmr-tox Workspace$ python3.5 --version
Python 3.5.2
Geoffreys-MBP:pydnmr-tox Workspace$ python3.6 --version
-bash: python3.6: command not found
Any ideas what is causing this behavior? tox/detox similarly cannot find any Python version besides 3.4/3.5.
Edit: it seems that pyenv has installed all the environments, but python3.x
commands weren't finding them. python3.4
and python3.5
were working because they found previous top-level installations. Results for pyenv which python3.x.y
vs. python3.x [--version]
shown below.
$ pyenv which python3.2
/Users/Workspace/.pyenv/versions/3.2.6/bin/python3.2
$ python3.2 --version
-bash: python3.2: command not found
$ python3.2
-bash: python3.2: command not found
pyenv which python3.3
/Users/Workspace/.pyenv/versions/3.3.6/bin/python3.3
$ python3.3 --version
-bash: python3.3: command not found
$ pyenv which python3.4
/usr/local/bin/python3.4 # old install
$ python3.4 --version
Python 3.4.3 # not 3.4.6 installed by pyenv
$ pyenv which python3.4.6
pyenv: python3.4.6: command not found
$ python3.4.6 --version
-bash: python3.4.6: command not found
$ pyenv which python3.5
/Users/Workspace/.pyenv/versions/3.5.3/bin/python3.5
$ python3.5 --version
Python 3.5.2 #Linked to my old 3.5.2 install instead of pyenv 3.5.3 install
$ pyenv which python3.6
/Users/Workspace/.pyenv/versions/3.6.1/bin/python3.6
$ python3.6 --version
-bash: python3.6: command not found
However, installing tox-pyenv as suggested in the answers below allowed tox to find and use all of these environments!
pyenv interpreter discovery is not integrated with tox core (yet). So everything that work is just because tox happens to find some with the unaware discovery methods it already applies.
There are two ways to make this work consistently:
Tell pyenv about all your interpreters in the context where you call tox. e.g. in the project where you want to run tox pyenv local system 3.2.6 3.3.6 3.4.6 3.5.3 3.6.1
Then tox should find all of them. If you want this to be the default wherever you are you cant set pyenv global
exactly like that. The first in the list is the interpreter that is invoked, when just calling python, but all others should also be active and therefore discoverable for tox.
If this doesn't do it for you for whatever reason or you like it to be a bit more automatic: there is a plugin - tox-pyenv that takes care of the discovery
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With