在 Ubuntu 16.04 中安装 pip 的问题⠀

在 Ubuntu 16.04 中安装 pip 的问题⠀

在 Ubuntu 16.04 中安装 pip 时出现问题。我猜它安装正确,但是当我检查时,pip -V它显示此错误:

anshul@ANSHUL:~$ sudo apt-get install python-pip
Reading package lists... Done
Building dependency tree       
Reading state information... Done
The following NEW packages will be installed:
  python-pip
0 upgraded, 1 newly installed, 0 to remove and 15 not upgraded.
Need to get 0 B/144 kB of archives.
After this operation, 635 kB of additional disk space will be used.
Selecting previously unselected package python-pip.
(Reading database ... 282702 files and directories currently installed.)
Preparing to unpack .../python-pip_8.1.1-2ubuntu0.4_all.deb ...
Unpacking python-pip (8.1.1-2ubuntu0.4) ...
Processing triggers for man-db (2.7.5-1) ...
Setting up python-pip (8.1.1-2ubuntu0.4) ...
anshul@ANSHUL:~$ pip -V
Traceback (most recent call last):
  File "/usr/bin/pip", line 9, in <module>
    from pip import main
ImportError: cannot import name main

答案1

尝试再次清除并安装 pip。我可以看到文件不是从存储库下载的,而是使用已下载的临时缓存进行安装。我建议进行全新安装,这可能会有所帮助。首先清除 pip 并在 apt 上执行自动清理和自动删除,然后尝试再次安装。

答案2

您可以尝试:

sudo apt-get autoremove 
sudo apt-get update
sudo easy_install pip==20.3.4

相关内容