安裝pandas的時候報錯:cannot uninstall 'numpy'. It is a distutils installed project and thus we ...

背景:

使用pip安裝Python的依賴庫pandas的時候報錯,錯誤提示類似如下所示:

Cannot uninstall 'numpy'. It is a distutils installed project and thus we cannot accurately determine which files belong to it which would lead to only a partial uninstall.

什麼意思呢???

簡單來說就是:安裝pandas的時候,會卸載掉你原來的numpy,再重新安裝一遍numpy(不清楚爲啥,可能是因爲自己帶的numpy版本更加契合pandas),然後咱們的電腦是已經裝過了numpy或者自帶了numpy,pandas表示你這個numpy老子不認,我要幫你刪了,但是因爲你的numpy是安裝在/system路徑下的,然後它自動幫你刪除又失敗了,所以你要先去刪掉自己的numpy。怎麼找到自己的numpy呢??

1、終端打開python,輸入import numpy

2、然後輸入import inspect

3、然後輸入inspect.getfile(numpy)

你就可以知道自己的numpy在哪裏了,去刪了就好,記得要刪乾淨!!!如果電腦是macOS,就算用sudo也刪不了,因爲mac有一個rootless保護機制。

如何關閉mac的rootless保護機制呢?????

1、重啓電腦,還在開機啓動的時候按住 Command-R 進入恢復分區.

2、在實用工具欄找到,終端啓動運行. 輸入: csrutil disable ,接着輸入 reboot 重啓電腦

建議在改完後後,還是改成enable。

 

整明白了這個之後,以後再遇到這個問題,就照葫蘆畫瓢,它刪不掉,咱們就自己刪,記得需要刪除乾淨!

emmm  ...

屢試不爽,真香!

發表評論
所有評論
還沒有人評論,想成為第一個評論的人麼? 請在上方評論欄輸入並且點擊發布.
相關文章