sudo pip を使用してプログラムをアンインストールできない

sudo pip を使用してプログラムをアンインストールできない

ネットで調べてみたのですが、どれもsudoコマンドを使うことを勧めていました。

sudo pip uninstall numpy

次のメッセージが表示されます:

Not uninstalling numpy at /usr/lib/python2.7/dist-packages, outside environment /usr

apt ではなく pip を使用してインストールしました。

出力:

 $ dpkg -S /usr/lib/python2.7/dist-packages/numpy
 python-numpy: /usr/lib/python2.7/dist-packages/numpy

PS: 私はMacユーザーで、通常はインストールにHomebrewを使用しているので、Ubuntuに関しては素人です。

答え1

の出力によるとdpkg -Snumpyは を使用してインストールされており、apt削除するには次を実行します。

sudo apt remove python-numpy

を使用してローカルにインストールしている場合pip、それを削除するには以下を使用できます。

pip uninstall numpy --user

答え2

オプションを使用します--isolated

以下のように:

sudo pip uninstall numpy --isolated

答え3

上記のヒントだけが役立ちました:

sudo apt remove python3-numpy 

->

The following packages were automatically installed and are no longer required:
  libjs-jquery-ui python-matplotlib-data python3-kiwisolver
Use 'sudo apt autoremove' to remove them.
The following packages will be REMOVED:
  python3-matplotlib python3-numpy
0 upgraded, 0 newly installed, 2 to remove and 1 not upgraded.
After this operation, 28.3 MB disk space will be freed.
Do you want to continue? [Y/n] y
(Reading database ... 389330 files and directories currently installed.)
Removing python3-matplotlib (3.1.2-1ubuntu4) ...
Removing python3-numpy (1:1.17.4-5ubuntu3) ...

ユーザーとして再インストールします:

pip3 install numpy 

答え4

/usr/lib/python3/dist-packagesnumpy に関連付けられた 2 つのディレクトリを編集して手動で削除することで問題を解決しました。

その後、パッケージを再インストールしました。

pip install numpy

関連情報