在 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

相關內容