简体   繁体   English

运行 tox 时“没有名为 pip 的模块”

[英]'no module named pip' when running tox

I have a simple tox file running basic python unit tests that I'm trying to run against multiple python versions.我有一个简单的 tox 文件,运行基本的 python 单元测试,我试图针对多个 python 版本运行它。

[tox]
envlist = py36, py37

[testenv]
setenv =
    PYTHONPATH = {toxinidir}

I used pyenv to manage the environments.我使用 pyenv 来管理环境。 My pyenv global is set to system.我的pyenv global设置为 system. I ran pyenv install 3.5.4 3.6.4 to install and the pyenv local ${version} to load them.我运行pyenv install 3.5.4 3.6.4来安装和pyenv local ${version}来加载它们。

ERROR: py36: InvocationError for command /Users/$user/workspace/${proj}/.tox/py36/bin/python -m pip freeze (exited with code 1)

py36-11.log 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.我检查了 python 位置,看到每个 python 文件夹中都有一个 pip 二进制文件。 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.我还尝试将 pip 添加到 tox 文件的require部分,在deps设置上设置 pip 并设置pip_pre true 以查看它是否会安装最新版本,但每次都得到相同的结果。 I don't see any other matches with google-fu or Stack so I'm assuming I've made a user error somewhere...我没有看到与 google-fu 或 Stack 的任何其他匹配项,所以我假设我在某处犯了用户错误......

The pyenv had been doing something strange to my paths. pyenv 对我的路径做了一些奇怪的事情。 I had to deactivate the virtualenv and then reactivate it.我不得不停用 virtualenv 然后重新激活它。 Now pyenv works with all python 3 versions I need.现在 pyenv 适用于我需要的所有 python 3 版本。 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.对于将来阅读本文的任何人,当我对这个问题进行研究时,它通常与某种路径问题有关。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM