2016-04-15 117 views
0

我嘗試從MacOSX中刪除所有安裝的pip軟件包。以下zsh循環刪除了其中的大部分,但一些抗拒。如何在MacOSX上清理pip安裝的軟件包?

for i ($(pip freeze)) {pip uninstall -y $i} 

例如matlibplot尚未被刪除。當我嘗試運行卸載它找到matplotlib,打印相關的路徑,但失敗。

pip uninstall matplotlib 
Uninstalling matplotlib-1.3.1: 
/System/Library/Frameworks/Python.framework/Versions/2.7/Extras/lib/python/matplotlib 
/System/Library/Frameworks/Python.framework/Versions/2.7/Extras/lib/python/matplotlib-1.3.1-py2.7.egg-info 
/System/Library/Frameworks/Python.framework/Versions/2.7/Extras/lib/python/pylab.py 
/System/Library/Frameworks/Python.framework/Versions/2.7/Extras/lib/python/pylab.pyc 
Proceed (y/n)? 

我收到以下非常長的錯誤消息。看來,文件不能被刪除。錯誤示例:

error: [('/System/Library/Frameworks/Python.framework/Versions/2.7/Extras/lib/python/matplotlib/__init__.py', '/tmp/pip-PK6UUB-uninstall/System/Library/Frameworks/Python.framework/Versions/2.7/Extras/lib/python/matplotlib/__init__.py', "[Errno 1] Operation not permitted: '/tmp/pip-PK6UUB-uninstall/System/Library/Frameworks/Python.framework/Versions/2.7/Extras/lib/python/matplotlib/__init__.py'"), 

我該怎麼辦?

爲了清楚起見,命令從root帳戶運行。皮普可以找到包的元數據:

pip show matplotlib 
--- 
Metadata-Version: 1.1 
Name: matplotlib 
Version: 1.3.1 
Summary: Python plotting package 
Home-page: http://matplotlib.org 
Author: John D. Hunter, Michael Droettboom 
Author-email: [email protected] 
License: BSD 
Location: /System/Library/Frameworks/Python.framework/Versions/2.7/Extras/lib/python 
Requires: numpy, python-dateutil, tornado, pyparsing, nose 
Classifiers: 
    Development Status :: 5 - Production/Stable 
    Intended Audience :: Science/Research 
    License :: OSI Approved :: Python Software Foundation License 
    Programming Language :: Python 
    Programming Language :: Python :: 2 
    Programming Language :: Python :: 3 
    Topic :: Scientific/Engineering :: Visualization 
+2

以root或sudo身份運行。 – han058

+0

我以root身份運行以上。 – Wawrzek

+1

我將問題提交給AskDiffrent:http://apple.stackexchange.com/questions/235041/how-to-clean-pip-installed-packages-on-macosx/235050#235050因爲我的問題似乎是MacOSX特有的。 – Wawrzek

回答

0

我假設matplotlib仍然顯示當你運行

$ pip freeze 

我不是那熟悉的OSX環境,但我會嘗試儘可能多的適應儘可能從Linux/GNU環境中進行。首先,你可以重新安裝matplotlib用命令:

$ pip install pysqlite 

它應該返回這樣的事情,如果PIP假定它已經被安裝

Requirement already satisfied (use --upgrade to upgrade): matplotlib in PATH 

使用這個返回的路徑,去PATH/dist-packages/matlibplot*.egg/ (或其他任何你將你的雞蛋存儲在你的python路徑中)並尋找installed-files.txt文件。如果它不存在,pip將無法卸載該軟件包。

因此,手動替代方法是刪除該蛋路徑中的所有文件,並清除matplotlib。您可能還必須編輯dist-packages目錄中的easy-install.*文件,並從中刪除matplotlib條目,以便pip freeze命令停止顯示它。

+0

有趣的想法,但我認爲這個問題是一個MacOSX方面。此外,點顯示matplotlib似乎足以獲取包信息 - 包括路徑。 – Wawrzek