步骤1

步骤1

我需要让一些软件在 Python 3.5 上运行

我正在使用 Ubuntu 21.10。

我收到此错误:

(foobar_addressbook) guettli@p15:~/foobar/projects/foobar_addressbook$ tox -e py35-django18 


py35-django18 create: /home/guettli/foobar/projects/foobar_addressbook/.tox/py35-django18
ERROR: invocation failed (exit code 1), logfile: /home/guettli/foobar/projects/foobar_addressbook/.tox/py35-django18/log/py35-django18-1.log
==================================================================== log start =====================================================================
Traceback (most recent call last):
  File "/usr/local/lib/python3.5/runpy.py", line 193, in _run_module_as_main
    "__main__", mod_spec)
  File "/usr/local/lib/python3.5/runpy.py", line 85, in _run_code
    exec(code, run_globals)
  File "/home/guettli/foobar/projects/foobar_addressbook/.tox/py35-django18/lib/python3.5/site-packages/pip/__main__.py", line 23, in <module>
    from pip._internal.cli.main import main as _main  # isort:skip # noqa
  File "/home/guettli/foobar/projects/foobar_addressbook/.tox/py35-django18/lib/python3.5/site-packages/pip/_internal/cli/main.py", line 10, in <module>
    from pip._internal.cli.autocompletion import autocomplete
  File "/home/guettli/foobar/projects/foobar_addressbook/.tox/py35-django18/lib/python3.5/site-packages/pip/_internal/cli/autocompletion.py", line 9, in <module>
    from pip._internal.cli.main_parser import create_main_parser
  File "/home/guettli/foobar/projects/foobar_addressbook/.tox/py35-django18/lib/python3.5/site-packages/pip/_internal/cli/main_parser.py", line 7, in <module>
    from pip._internal.cli import cmdoptions
  File "/home/guettli/foobar/projects/foobar_addressbook/.tox/py35-django18/lib/python3.5/site-packages/pip/_internal/cli/cmdoptions.py", line 23, in <module>
    from pip._vendor.packaging.utils import canonicalize_name
ImportError: No module named 'pip._vendor.packaging'

===================================================================== log end ======================================================================
_____________________________________________________________________ summary ______________________________________________________________________
ERROR:   py35-django18: InvocationError for command /home/guettli/foobar/projects/foobar_addressbook/.tox/py35-django18/bin/python -m pip freeze (exited with code 1)

知道如何修复此错误吗?

相关问题:安装 Python 3.5:ensurepip 时出现分段错误

答案1

步骤1

虚拟环境中的 pip 似乎坏了,因此引导 pip:

curl  https://bootstrap.pypa.io/pip/3.5/get-pip.py | .tox/py35-django18/bin/python - 

第2步

现在我收到这个错误

    ERROR: Command errored out with exit status 1:
     command: /home/guettli/foobar/projects/foobar_addressbook/.tox/py35-django18/bin/python -c 'import sys, setuptools, tokenize; sys.argv[0] = '"'"'/tmp/pip-install-xsbc7r69/django-celery_63fa83d5391f499a9cc375c1c1fed8b6/setup.py'"'"'; __file__='"'"'/tmp/pip-install-xsbc7r69/django-celery_63fa83d5391f499a9cc375c1c1fed8b6/setup.py'"'"';f=getattr(tokenize, '"'"'open'"'"', open)(__file__);code=f.read().replace('"'"'\r\n'"'"', '"'"'\n'"'"');f.close();exec(compile(code, __file__, '"'"'exec'"'"'))' egg_info --egg-base /tmp/pip-pip-egg-info-6esk_zf9
         cwd: /tmp/pip-install-xsbc7r69/django-celery_63fa83d5391f499a9cc375c1c1fed8b6/
    Complete output (7 lines):
    Traceback (most recent call last):
      File "<string>", line 1, in <module>
      File "/home/guettli/foobar/projects/foobar_addressbook/.tox/py35-django18/lib/python3.5/site-packages/setuptools/__init__.py", line 18, in <module>
        import setuptools.version
      File "/home/guettli/foobar/projects/foobar_addressbook/.tox/py35-django18/lib/python3.5/site-packages/setuptools/version.py", line 1, in <module>
        import pkg_resources
    ImportError: No module named 'pkg_resources'

修复这个问题:

.tox/py35-django18/bin/python -m pip install -U setuptools

现在 tox 的虚拟环境正在运行。

如果你知道在 Ubuntu 21.10 上运行 Python3.5 的更简单方法,请发表评论。谢谢。

相关内容