当我跑步时
pip install --upgrade pip
我收到此错误消息:
Collecting pip
Downloading pip-8.1.0-py2.py3-none-any.whl (1.2MB)
100% |████████████████████████████████| 1.2MB 371kB/s
Installing collected packages: pip
Found existing installation: pip 8.0.2
Uninstalling pip-8.0.2:
Exception:
Traceback (most recent call last):
File "/Library/Python/2.7/site-packages/pip/basecommand.py", line 209, in main
status = self.run(options, args)
File "/Library/Python/2.7/site-packages/pip/commands/install.py", line 317, in run
prefix=options.prefix_path,
File "/Library/Python/2.7/site-packages/pip/req/req_set.py", line 725, in install
requirement.uninstall(auto_confirm=True)
File "/Library/Python/2.7/site-packages/pip/req/req_install.py", line 752, in uninstall
paths_to_remove.remove(auto_confirm)
File "/Library/Python/2.7/site-packages/pip/req/req_uninstall.py",line 115, in remove
renames(path, new_path)
File "/Library/Python/2.7/site-packages/pip/utils/__init__.py", line 266, in renames
shutil.move(old, new)
File"/System/Library/Frameworks/Python.framework/Versions/2.7/lib/python2.7/shutil.py", line 303, in move
os.unlink(src)
OSError: [Errno 13] Permission denied: '/Library/Python/2.7/site- packages/pip-8.0.2.dist-info/DESCRIPTION.rst'
以前我一直在努力安装和运行几个python模块,所以我记得有点移动文件。这是什么导致了这个错误?我怎样才能解决这个问题?我在Mac上。
我之前尝试安装bs4,我收到了类似的错误消息。 (但我怀疑bs4安装有更多问题,所以这是以后的另一个问题)。
对于代码的任何格式问题也很抱歉。我尽力让它看起来像在终端上。
感谢。
答案 0 :(得分:4)
权限问题意味着您的用户权限不允许您在所需的文件夹(/Library/Python/2.7/site-packages/pip/
)上书写。基本上你可以做两件事:
答案 1 :(得分:0)
我在 Windows 中遇到了类似的问题-因此,我找到了这个旧帖子。就像Bernardo所说的那样,我需要我的pip命令具有更高的权限,才能将升级文件写入受保护的文件夹。在Windows 7中运行时,从未发生过错误。只是当我升级到Windows 10时:默认情况下,W10并未以管理员身份打开CMD窗口。
对我来说,解决方案是打开一个具有管理员权限的CMD窗口(例如开始-> cmd->右键单击“命令窗口”,然后选择“以管理员身份运行” )。在这个新的cmd窗口中,pip命令效果更好。
我本来可以在贝尔纳多(Bernardo)的回答下发表此评论,但是我还没有权限在Stack Overflow中发表评论。
答案 2 :(得分:0)
在管理员模式命令提示符下,您可以运行以下命令,该命令应该可以解决此问题:
python -m ensurepip --user
如果您的版本支持python3,请替换它。
答案 3 :(得分:0)
最好的方法如下:
$ python3 -m pip install --upgrade pip
因为通常不建议使用
$ sudo pip install
更多答案可以在这里找到:https://github.com/pypa/pip/issues/5599
答案 4 :(得分:0)
DEPRECATION: Python 2.7 will reach the end of its life on January 1st, 2020. Please upgrade your Python as Python 2.7 won't be maintained after that date. A future version of pip will drop support for Python 2.7. More details about Python 2 support in pip, can be found at https://pip.pypa.io/en/latest/development/release-process/#python-2-support
ERROR: Could not open requirements file: [Errno 2] No such file or directory: 'requirement.txt'
WARNING: You are using pip version 19.2.3, however version 20.3.4 is available.
You should consider upgrading via the 'pip install --upgrade pip' command.
$ pip install pip
Requirement already satisfied: pip in /data/data/com.termux/files/usr/lib/python3.9/site-packages (21.0.1)
显示这样的帮助!!!