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 を消去して再度インストールしてみてください。ファイルがリポジトリからダウンロードされていないことがわかります。すでにダウンロードされている temp のキャッシュを使用してインストールされています。クリーン インストールを行うことをお勧めします。これが役立つ場合があります。まず pip を消去し、apt で自動クリーンおよび自動削除を実行してから、再度インストールしてみてください。

答え2

以下をお試しください:

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

関連情報