I have a simple tox file running basic python unit tests that I'm trying to run against multiple python versions.
[tox]
envlist = py36, py37
[testenv]
setenv =
PYTHONPATH = {toxinidir}
I used pyenv to manage the environments. My pyenv global
is set to system. I ran pyenv install 3.5.4 3.6.4
to install and the pyenv local ${version}
to load them.
ERROR: py36: InvocationError for command /Users/$user/workspace/${proj}/.tox/py36/bin/python -m pip freeze (exited with code 1)
py36-11.log
action: py36, msg: envreport
cwd: /Users/$user/workspace/${proj}
cmd: /Users/$user/workspace/${proj}/.tox/py36/bin/python -m pip freeze
/Users/$user/workspace/${proj}/.tox/py36/bin/python: No module named pip
Full Tox Output
GLOB sdist-make: /Users/${user}/workspace/${proj}/setup.py
py36 inst-nodeps: /Users/${user}/workspace/${proj}/.tox/.tmp/package/1/tally_ho-0.1.0.zip
ERROR: invocation failed (exit code 1), logfile: /Users/${user}/workspace/${proj}/.tox/py36/log/py36-11.log
================================================================================================================================== log start ===================================================================================================================================
/Users/${user}/workspace/${proj}/.tox/py36/bin/python: No module named pip
=================================================================================================================================== log end ====================================================================================================================================
py37 inst-nodeps: /Users/${user}/workspace/${proj}/.tox/.tmp/package/1/tally_ho-0.1.0.zip
py37 installed: attrs==20.2.0,importlib-metadata==1.7.0,iniconfig==1.0.1,more-itertools==8.5.0,packaging==20.4,pluggy==0.13.1,py==1.9.0,pyparsing==2.4.7,pytest==6.0.2,six==1.15.0,${proj}==0.1.0,toml==0.10.1,zipp==3.1.0
py37 run-test-pre: PYTHONHASHSEED='1245480162'
py37 run-test: commands[0] | pytest
============================================================================================================================= test session starts ==============================================================================================================================
platform darwin -- Python 3.7.7, pytest-6.0.2, py-1.9.0, pluggy-0.13.1
cachedir: .tox/py37/.pytest_cache
rootdir: /Users/${user}/workspace/${proj}
collected 22 items
tests/test_cmd.py ....... [ 31%]
tests/test_config.py .... [ 50%]
tests/test_proj.py ........... [100%]
============================================================================================================================== 22 passed in 0.19s ==============================================================================================================================
___________________________________________________________________________________________________________________________________ summary ____________________________________________________________________________________________________________________________________
ERROR: py36: InvocationError for command /Users/${user}/workspace/${proj}/.tox/py36/bin/python -m pip freeze (exited with code 1)
$ pyenv --version
pyenv 1.2.1
$ tox --version
3.20.0 imported from /Users/${user}/.virtualenvs/${proj}/lib/python3.7/site-packages/tox/__init__.py
$pyenv local
3.6.4
I checked the python location and see that there is a pip binary in each python folder. I also tried adding pip to the require
section of the tox file, setting pip on the deps
setting and setting pip_pre
true to see if it would install the latest version, but I get the same result each time. I don't see any other matches with google-fu or Stack so I'm assuming I've made a user error somewhere...
The pyenv had been doing something strange to my paths. I had to deactivate the virtualenv and then reactivate it. Now pyenv works with all python 3 versions I need. For anyone reading this in the future, when I did my research on this problem, it was often related to some kind of path issue.