Python 3 的 tox 调用失败

tox Invocation failed for Python 3

tox 运行我的 Python 2.7 测试,但在 Python 3.4 中失败。它给出了 "Invocation failed" 消息。摘录:

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']

以后

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)

您需要查看错误消息的详细信息。注意失败的命令(来自第一个摘录):

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

您可以 运行 手动执行此操作:

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

假设您看到同样的错误,那么您的问题是 virtualenv 而不是 tox。

我查看了 virtualenv 帮助页面,这似乎应该可行。面对可能的错误,第一步是升级 Python、virtualenv 或其他库。

就我而言,升级 virtualenv 是解决方案:

pip install --upgrade virtualenv

有趣的是,这个解决方案在 Windows 和 Linux 上都有效。最有可能的是,在我获得 virtualenv 和最新版本之间存在错误修复。