Python 版本依赖问题 - pip uninstall

标签 python matplotlib pip

我在尝试卸载 matplotlib 或升级 pip 时遇到错误。例如:

%pip install --upgrade pip  

下载并安装 pip 后,它会尝试卸载旧版本。我收到错误:

You are using pip version 7.1.0, however version 8.0.2 is available.
You should consider upgrading via the 'pip install --upgrade pip' command.
Collecting pip  
  Downloading pip-8.0.2-py2.py3-none-any.whl (1.2MB)  
    100% |████████████████████████████████| 1.2MB 506kB/s   
Installing collected packages: pip  
  Found existing installation: pip 7.1.0  
    Uninstalling pip-7.1.0:  
Exception:  
Traceback (most recent call last):  
  File "/Library/Python/2.7/site-packages/pip-7.1.0-py2.7.egg/pip/basecommand.py", line 223, in main
    status = self.run(options, args)  
  File "/Library/Python/2.7/site-packages/pip-7.1.0-py2.7.egg/pip/commands/install.py", line 299, in run
    root=options.root_path,  
  File "/Library/Python/2.7/site-packages/pip-7.1.0-py2.7.egg/pip/req/req_set.py", line 640, in install
    requirement.uninstall(auto_confirm=True)  
  File "/Library/Python/2.7/site-packages/pip-7.1.0-py2.7.egg/pip/req/req_install.py", line 726, in uninstall
    paths_to_remove.remove(auto_confirm)  
  File "/Library/Python/2.7/site-packages/pip-7.1.0-py2.7.egg/pip/req/req_uninstall.py", line 125, in remove
    renames(path, new_path)  
  File "/Library/Python/2.7/site-packages/pip-7.1.0-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.1.0-py2.7.egg/EGG-INFO/dependency_links.txt'

如有任何指导,我们将不胜感激。

最佳答案

试试这个:sudo pip install --upgrade pip

为什么 sudosudo 始终以 super 用户权限(作为 root)运行。因此 sudo 有能力执行一些特权任务,比如调用只允许 root 用户使用的系统函数。由于您收到 permission denied 错误,使用 sudo 运行相同的命令将不会请求权限,因为您是 root

关于Python 版本依赖问题 - pip uninstall,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/35329135/

相关文章:

python - Numpy 数组到字典

python - Windrose 图例括号格式和位置

python - 设置范围时忽略投影限制

linux - 如何通过 pip 安装 vowpalwabbit

python - 同时使用组和个人权限

python - pandas 在删除重复项时在 GroupBy 之后丢失索引

python - 使用 pip 安装私有(private) github 存储库时遇到问题

visual-studio-2010 - Python 错误 : command '...\Microsoft Visual Studio 10.0\\VC\\BIN\\cl.exe' failed with exit status 2

Python tkinter Entry 小部件显示条形字符而不是换行符

python - 使用用户 tkinter 输入作为 Matplotlib 的坐标绘制一条线