2017-01-09 159 views
4

我在OS X 10.11.6上。我今天更新和升級了brew。之後,pip沒有工作。它看起來好像在升級過程中沒有安裝它。當我完成了升級,我看到了警告:brew後安裝python(2.7.13):[Errno 13] Permission denied

Warning: The post-install step did not complete successfully You can try again using brew postinstall python 

於是我就brew postinstall python,然後我遇到的錯誤:

error: [Errno 13] Permission denied: '/usr/local/lib/python2.7/site-packages/pkg_resources/__init__.py' 

this後,他們說:

The post-install step did not complete successfully due to error: could not delete '/usr/local/lib/python2.7/site-packages/pip/__init__.py': Permission denied. Manually deleting that file and then running brew postinstall python again fixed it.

所以我認爲修復將是相同的,我手動刪除/usr/local/lib/python2.7/site-packages/pkg_resources/__init__.py',以便

$ ls /usr/local/lib/python2.7/site-packages/pkg_resources/ 
_vendor extern 

我又跑brew postinstall python但現在我得到:

... 
copying build/lib/easy_install.py -> /usr/local/lib/python2.7/site-packages 
copying build/lib/pkg_resources/__init__.py -> /usr/local/lib/python2.7/site-packages/pkg_resources 
error: [Errno 13] Permission denied: '/usr/local/lib/python2.7/site-packages/pkg_resources/__init__.py'` 

我找到了 「修復」 使用easy_install安裝PIP:

sudo easy_install pip 

而現在一切似乎很好地工作。不過,我有兩個問題:

  1. 我是不是已經搞亂了手動刪除'/usr/local/lib/python2.7/site-packages/pkg_resources/__init__.py'

  2. brew postinstall python[Errno 13] Permission denied會修復什麼?


如果它沒有任何用處的,這裏是我的brew configbrew doctor輸出畢竟今天發生:

$ brew config 
HOMEBREW_VERSION: 1.1.6 
ORIGIN: https://github.com/Homebrew/brew 
HEAD: 619791e83d2781dca1b675e20249a8aebe085c7c 
Last commit: 6 days ago 
Core tap ORIGIN: https://github.com/Homebrew/homebrew-core 
Core tap HEAD: 5ce01ec9c8b9958e2d9a7791e4d4e2aa0bf4fd8f 
Core tap last commit: 89 minutes ago 
HOMEBREW_PREFIX: /usr/local 
HOMEBREW_REPOSITORY: /usr/local/Homebrew 
HOMEBREW_CELLAR: /usr/local/Cellar 
HOMEBREW_BOTTLE_DOMAIN: https://homebrew.bintray.com 
CPU: octa-core 64-bit haswell 
Homebrew Ruby: 2.0.0-p648 
Clang: 8.0 build 800 
Git: 2.10.1 => /Applications/Xcode.app/Contents/Developer/usr/bin/git 
Perl: /usr/bin/perl 
Python: /usr/local/bin/python => /usr/local/Cellar/python/2.7.13/Frameworks/Python.framework/Versions/2.7/bin/python2.7 
Ruby: /usr/bin/ruby => /System/Library/Frameworks/Ruby.framework/Versions/2.0/usr/bin/ruby 
Java: 1.8.0_91 
macOS: 10.11.6-x86_64 
Xcode: 8.2.1 
CLT: 8.2.0.0.1.1480973914 
X11: 2.7.11 => /opt/X11 

$ brew doctor 
Warning: Unbrewed dylibs were found in /usr/local/lib. 
If you didn't put them there on purpose they could cause problems when 
building Homebrew formulae, and may need to be deleted. 

Unexpected dylibs: 
    /usr/local/lib/libtcl8.6.dylib 
    /usr/local/lib/libtk8.6.dylib 

Warning: Unbrewed header files were found in /usr/local/include. 
If you didn't put them there on purpose they could cause problems when 
building Homebrew formulae, and may need to be deleted. 

Unexpected header files: 
    /usr/local/include/fakemysql.h 
    /usr/local/include/fakepq.h 
    /usr/local/include/fakesql.h 
    /usr/local/include/itcl.h 
    /usr/local/include/itcl2TclOO.h 
    /usr/local/include/itclDecls.h 
    /usr/local/include/itclInt.h 
    /usr/local/include/itclIntDecls.h 
    /usr/local/include/itclMigrate2TclCore.h 
    /usr/local/include/itclTclIntStubsFcn.h 
    /usr/local/include/mysqlStubs.h 
    /usr/local/include/odbcStubs.h 
    /usr/local/include/pqStubs.h 
    /usr/local/include/tcl.h 
    /usr/local/include/tclDecls.h 
    /usr/local/include/tclOO.h 
    /usr/local/include/tclOODecls.h 
    /usr/local/include/tclPlatDecls.h 
    /usr/local/include/tclThread.h 
    /usr/local/include/tclTomMath.h 
    /usr/local/include/tclTomMathDecls.h 
    /usr/local/include/tdbc.h 
    /usr/local/include/tdbcDecls.h 
    /usr/local/include/tdbcInt.h 
    /usr/local/include/tk.h 
    /usr/local/include/tkDecls.h 
    /usr/local/include/tkPlatDecls.h 

Warning: Unbrewed .pc files were found in /usr/local/lib/pkgconfig. 
If you didn't put them there on purpose they could cause problems when 
building Homebrew formulae, and may need to be deleted. 

Unexpected .pc files: 
    /usr/local/lib/pkgconfig/tcl.pc 
    /usr/local/lib/pkgconfig/tk.pc 

Warning: Unbrewed static libraries were found in /usr/local/lib. 
If you didn't put them there on purpose they could cause problems when 
building Homebrew formulae, and may need to be deleted. 

Unexpected static libraries: 
    /usr/local/lib/libtclstub8.6.a 
    /usr/local/lib/libtkstub8.6.a 

回答

11

我發現的最簡單的方法解決這個問題是隻需將文件夾的所有權設置爲您的用戶名:

chown -R `whoami` /usr/local/lib/python2.7/site-packages/ 

編輯:有時,我也運行此:

sudo -H python3 -m pip install ... 

sudo -H pip install 
+0

那樣簡單(捂臉)。有效。非常感謝 – Javier

相關問題