注意 Ubuntu 版本:

注意 Ubuntu 版本:

当我跑步时

#pip3 

命令我收到以下错误。

Traceback (most recent call last):
  File "/usr/bin/pip3", line 9, in <module>
    from pip import main
  File "/usr/lib/python2.7/dist-packages/pip/__init__.py", line 16, in <module>
    from pip.vcs import git, mercurial, subversion, bazaar  # noqa
  File "/usr/lib/python2.7/dist-packages/pip/vcs/subversion.py", line 9, in <module>
    from pip.index import Link
  File "/usr/lib/python2.7/dist-packages/pip/index.py", line 30, in <module>
    from pip.wheel import Wheel, wheel_ext
  File "/usr/lib/python2.7/dist-packages/pip/wheel.py", line 6, in <module>
    import compileall
  File "/usr/lib/python3.5/compileall.py", line 20, in <module>
    from concurrent.futures import ProcessPoolExecutor
  File "/usr/lib/python2.7/dist-packages/concurrent/futures/__init__.py", line 8, in <module>
    from concurrent.futures._base import (FIRST_COMPLETED,
  File "/usr/lib/python2.7/dist-packages/concurrent/futures/_base.py", line 357
    raise type(self._exception), self._exception, self._traceback
                               ^
SyntaxError: invalid syntax

我试图解决什么?

步骤 1 - 卸载

sudo apt-get remove python3-pip

第 2 步 - 删除目录

   /usr/local/lib/python3.5/dist-packages

第 3 步 - 重新安装 pip3

sudo apt-get install python3-pip

当我运行 pip3 命令时,仍然出现上述相同的错误。

非常感谢您的帮助?

注意 Ubuntu 版本:

DISTRIB_ID=Ubuntu

分发版本=16.04

DISTRIB_CODENAME=xenial

DISTRIB_DESCRIPTION="Ubuntu 16.04.5 LTS"

答案1

PYTHONPATH当在某处设置时,有时会发生此问题。

要查看是否已设置,请运行以下命令:

echo $PYTHONPATH 

如果命令返回路径,则需要取消设置PYTHONPATH

如果您已设置它,请~/.bashrc注释掉该行PYTHONPATH然后运行:

. ~/.bashrc 

找到文件然后运行:

export PYTHONPATH='' 

为好措施。

参考文献1参考文献2

另请参阅这个相关问题

相关内容