简体   繁体   中英

pip install/upgrade error for Python2.7, 3.4

Python Version=2.7, 3.4 So I'm trying to update pip since I get the following message in the terminal. You are using pip version 7.0.3, however version 7.1.2 is available. You should consider upgrading via the 'pip install --upgrade pip' command.

and this.

Collecting pip
Using cached pip-7.1.2-py2.py3-none-any.whl 
Installing collected packages: pip
Found existing installation: pip 7.0.3
Uninstalling pip-7.0.3:

and then I get an error that says,

  Exception:
  Traceback (most recent call last):
  File "/Library/Python/2.7/site-packages/pip-7.0.3-py2.7.egg/pip/basecommand.py", line 223, in main
    status = self.run(options, args)
  File "/Library/Python/2.7/site-packages/pip-7.0.3-py2.7.egg/pip/commands/install.py", line 297, in run
    root=options.root_path,
  File "/Library/Python/2.7/site-packages/pip-7.0.3-py2.7.egg/pip/req/req_set.py", line 616, in install
    requirement.uninstall(auto_confirm=True)
  File "/Library/Python/2.7/site-packages/pip-7.0.3-py2.7.egg/pip/req/req_install.py", line 721, in uninstall
    paths_to_remove.remove(auto_confirm)
  File "/Library/Python/2.7/site-packages/pip-7.0.3-py2.7.egg/pip/req/req_uninstall.py", line 126, in remove
    renames(path, new_path)
  File "/Library/Python/2.7/site-packages/pip-7.0.3-py2.7.egg/pip/utils/__init__.py", line 314, 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-7.0.3-py2.7.egg/EGG-INFO/dependency_links.txt'

How do I fix this error?

The installation needs file permissions that you don't have. run with sudo ( sudo pip install ...) or as root user. You will need the root password for that.

The unix standard file system hierarchy is such a normal user (even an administrator) don't have write permissions to most places outside their homedir. To change things in the "global" paths of the hierarchy you need to have higher permissions. root is generally the high permissions user. running a command by prefixing it with sudo means running it as another user and usually with root permissions, it can then write to places such /Library where pip is trying to install.

Some more about the standard: https://en.wikipedia.org/wiki/Filesystem_Hierarchy_Standard

尝试从/Library/Python/2.7/site-packages/中删除pip-7.0.3-py2.7.eggpip .pth * ,然后尝试在终端中执行pip install --upgrade pip命令

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM