简体   繁体   English

Python 3的tox调用失败

[英]tox Invocation failed for Python 3

tox runs my Python 2.7 tests, but fails for Python 3.4. tox运行我的Python 2.7测试,但是Python 3.4失败了。 It gives an "Invocation failed" message. 它给出了“调用失败”消息。 Excerpts: 摘录:

py34 create: /home/josh/code/ezoutlet/.tox/py34
ERROR: invocation failed (exit code 1), logfile: /home/josh/code/ezoutlet/.tox/py34/log/py34-0.log
ERROR: actionid: py34
msg: getenv
cmdargs: ['/usr/bin/python', '-m', 'virtualenv', '--python', '/usr/bin/python3.4', 'py34']

And later 然后

Traceback (most recent call last):
  File "/usr/local/lib/python2.7/dist-packages/virtualenv.py", line 8, in <module>
    import base64
  File "/usr/lib/python3.4/base64.py", line 9, in <module>
    import re
  File "/usr/lib/python3.4/re.py", line 336, in <module>
    import copyreg
  File "/usr/local/lib/python2.7/dist-packages/copyreg/__init__.py", line 7, in <module>
    raise ImportError('This package should not be accessible on Python 3. '
ImportError: This package should not be accessible on Python 3. Either you are trying to run from the python-future src folder or your installation of python-future is corrupted.
Error in sys.excepthook:
Traceback (most recent call last):
  File "/usr/lib/python3/dist-packages/apport_python_hook.py", line 53, in apport_excepthook
    if not enabled():
  File "/usr/lib/python3/dist-packages/apport_python_hook.py", line 24, in enabled
    import re
  File "/usr/lib/python3.4/re.py", line 336, in <module>
    import copyreg
  File "/usr/local/lib/python2.7/dist-packages/copyreg/__init__.py", line 7, in <module>
    raise ImportError('This package should not be accessible on Python 3. '
ImportError: This package should not be accessible on Python 3. Either you are trying to run from the python-future src folder or your installation of python-future is corrupted.

Original exception was:
Traceback (most recent call last):
  File "/usr/local/lib/python2.7/dist-packages/virtualenv.py", line 8, in <module>
    import base64
  File "/usr/lib/python3.4/base64.py", line 9, in <module>
    import re
  File "/usr/lib/python3.4/re.py", line 336, in <module>
    import copyreg
  File "/usr/local/lib/python2.7/dist-packages/copyreg/__init__.py", line 7, in <module>
    raise ImportError('This package should not be accessible on Python 3. '
ImportError: This package should not be accessible on Python 3. Either you are trying to run from the python-future src folder or your installation of python-future is corrupted.
Running virtualenv with interpreter /usr/bin/python3.4

ERROR: InvocationError: /usr/bin/python -m virtualenv --python /usr/bin/python3.4 py34 (see /home/josh/code/ezoutlet/.tox/py34/log/py34-0.log)

You need to look at the details of the error message. 您需要查看错误消息的详细信息。 Notice the command that failed (from the first excerpt): 注意失败的命令(来自第一个摘录):

cmdargs: ['/usr/bin/python', '-m', 'virtualenv', '--python', '/usr/bin/python3.4', 'py34']

You can run this manually with: 您可以使用以下方式手动运行:

/usr/bin/python -m virtualenv --python /usr/bin/python3.4 py34

Assuming you see the same error, your issue is with virtualenv rather than tox. 假设你看到同样的错误,你的问题是使用virtualenv而不是tox。

I reviewed the virtualenv help page and it seems like this should work. 我查看了virtualenv帮助页面,看起来这应该有效。 Faced with a possible bug, a good first step is to upgrade Python, virtualenv, or other libraries. 面对可能的错误,首先要升级Python,virtualenv或其他库。

In my case, upgrading virtualenv was the solution: 就我而言,升级virtualenv是解决方案:

pip install --upgrade virtualenv

Interestingly, this solution worked on both Windows and Linux. 有趣的是,这个解决方案适用于Windows和Linux。 Most likely, there was a bug fix between when I got virtualenv and the latest release. 最有可能的是,当我获得virtualenv和最新版本之间存在错误修复。

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

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