2015-10-04 64 views
6

我試圖升級我的iMac上的點子,但我不斷收到權限被拒絕的錯誤。我是管理員,所以我不知道我做錯了什麼。無法升級點。沒有權限。爲什麼?

iMac:~ me$ pip install --upgrade pip 
    You are using pip version 6.0.8, however version 7.1.2 is available. 
    You should consider upgrading via the 'pip install --upgrade pip' command. 
    Collecting pip from https://pypi.python.org/packages/py2.py3/p/pip/pip-7.1.2-py2.py3-none-any.whl#md5=5ff9fec0be479e4e36df467556deed4d 
     Downloading pip-7.1.2-py2.py3-none-any.whl (1.1MB) 
     100% |################################| 1.1MB 181kB/s 
    Installing collected packages: pip 
     Found existing installation: pip 6.0.8 
     Uninstalling pip-6.0.8: 
      Exception: 
      Traceback (most recent call last): 
      File "/Library/Python/2.7/site-packages/pip-6.0.8-py2.7.egg/pip/basecommand.py", line 232, in main 
       status = self.run(options, args) 
      File "/Library/Python/2.7/site-packages/pip-6.0.8-py2.7.egg/pip/commands/install.py", line 347, in run 
       root=options.root_path, 
      File "/Library/Python/2.7/site-packages/pip-6.0.8-py2.7.egg/pip/req/req_set.py", line 543, in install 
       requirement.uninstall(auto_confirm=True) 
      File "/Library/Python/2.7/site-packages/pip-6.0.8-py2.7.egg/pip/req/req_install.py", line 667, in uninstall 
       paths_to_remove.remove(auto_confirm) 
      File "/Library/Python/2.7/site-packages/pip-6.0.8-py2.7.egg/pip/req/req_uninstall.py", line 126, in remove 
       renames(path, new_path) 
      File "/Library/Python/2.7/site-packages/pip-6.0.8-py2.7.egg/pip/utils/__init__.py", line 316, in renames 
       shutil.move(old, new) 
      File "/System/Library/Frameworks/Python.framework/Versions/2.7/lib/python2.7/shutil.py", line 300, in move 
       rmtree(src) 
      File "/System/Library/Frameworks/Python.framework/Versions/2.7/lib/python2.7/shutil.py", line 247, in rmtree 
       rmtree(fullname, ignore_errors, onerror) 
      File "/System/Library/Frameworks/Python.framework/Versions/2.7/lib/python2.7/shutil.py", line 252, in rmtree 
       onerror(os.remove, fullname, sys.exc_info()) 
      File "/System/Library/Frameworks/Python.framework/Versions/2.7/lib/python2.7/shutil.py", line 250, in rmtree 
       os.remove(fullname) 
      OSError: [Errno 13] Permission denied: '/Library/Python/2.7/site-packages/pip-6.0.8-py2.7.egg/EGG-INFO/dependency_links.txt' 

我不知道我在這裏做錯了什麼,因爲升級看起來相當簡單。

感謝,

+1

如何在'sudo'前面運行它? – Cleb

回答

14

pip安裝需要提升

sudo pip install --upgrade pip 

僅僅因爲你目前使用的是管理員帳戶,並不意味着該命令將隨海拔高度運行,除非你指定sudo

+0

FWIW您應該提及,使用sudo與pip但不是虛擬環境 – styvane

1

你可以做兩種方法之一:

  1. chown -R user /path/to/file一個更詳細的信息可以在這個SO文章中找到,但它並不涉及它處理同一問題的確切問題。
  2. 快速和骯髒的方式只是做pip install --upgrade pip已經提到過。但是,許多用戶會反對這一點。
2

您必須使用sudo,因爲您正在全局升級pip。我更喜歡安裝Homebrew並讓Homebrew管理一切。

  1. 從App Store
  2. 安裝Xcode的安裝自制軟件 - ruby -e "$(curl -fsSL https://raw.githubusercontent.com/Homebrew/install/master/install)"
  3. 安裝Python - brew install python,這也將安裝點子。

使用此設置,所有內容都安裝在本地,不需要您運行sudo

我希望這會有所幫助。

+0

您也可以使用'brew install python3'安裝Python 3。 – joshlsullivan