python - 使用 pip 安装烧瓶时出现权限被拒绝错误
问题描述
我尝试pip install flask
在 Arch Linux 上运行,但出现以下错误:
Collecting itsdangerous>=0.24 (from flask)
Using cached https://files.pythonhosted.org/packages/dc/b4/a60bcdba945c00f6d608d8975131ab3f25b22f2bcfe1dab221165194b2d4/itsdangerous-0.24.tar.gz
Collecting MarkupSafe>=0.23 (from Jinja2>=2.10->flask)
Using cached https://files.pythonhosted.org/packages/4d/de/32d741db316d8fdb7680822dd37001ef7a448255de9699ab4bfcbdf4172b/MarkupSafe-1.0.tar.gz
Installing collected packages: Werkzeug, click, MarkupSafe, Jinja2, itsdangerous, flask
Running setup.py install for MarkupSafe ... done
Running setup.py install for itsdangerous ... error
Complete output from command /usr/bin/python -u -c "import setuptools, tokenize;__file__='/tmp/pip-build-9u23zlnf/itsdangerous/setup.py';f=getattr(tokenize, 'open', open)(__file__);code=f.read().replace('\r\n', '\n');f.close();exec(compile(code, __file__, 'exec'))" install --record /tmp/pip-r51zrnnv-record/install-record.txt --single-version-externally-managed --compile:
running install
running build
running build_py
creating build
creating build/lib
copying itsdangerous.py -> build/lib
running install_lib
copying build/lib/itsdangerous.py -> /usr/lib/python3.6/site-packages
byte-compiling /usr/lib/python3.6/site-packages/itsdangerous.py to itsdangerous.cpython-36.pyc
error: [Errno 13] Permission denied: '/usr/lib/python3.6/site-packages/__pycache__/itsdangerous.cpython-36.pyc.140591598548528'
----------------------------------------
Command "/usr/bin/python -u -c "import setuptools, tokenize;__file__='/tmp/pip-build-9u23zlnf/itsdangerous/setup.py';f=getattr(tokenize, 'open', open)(__file__);code=f.read().replace('\r\n', '\n');f.close();exec(compile(code, __file__, 'exec'))" install --record /tmp/pip-r51zrnnv-record/install-record.txt --single-version-externally-managed --compile" failed with error code 1 in /tmp/pip-build-9u23zlnf/itsdangerous/
You are using pip version 9.0.1, however version 10.0.1 is available.
You should consider upgrading via the 'pip install --upgrade pip' command.`
这个错误是什么意思?
解决方案
利用
pip install --user flask
反而。
您收到 Permission Denied 错误,这意味着您无权写入特定位置。
当你在使用pip install flask
时,pip
会尝试将包安装在flask
某处/usr/lib/python3.6/../
。这个目录需要你在运行时没有的 root 访问权限pip install flask
。
通过使用该--user
标志,您可以pip
将软件包安装到不需要 root 权限的主目录。
使用该--user
标志安装 Python 包始终是一个好习惯,因为您没有在系统范围内安装该包。当您使用时,您sudo pip install package_name
将在系统范围内安装/升级包(带有依赖项)。某些系统中的 Python 会启动关键系统组件,强制系统安装新版本的软件包可能会破坏某些关键系统组件。通常,系统会坚持使用特定的软件包版本只是为了支持向后兼容性,如果您尝试将其安装为 sudo,则可能会破坏这一点。
推荐阅读
- c# - 后处理:在特定图层上禁用运动模糊
- vb.net - 如何使用 vb.net 根据另一个下拉列表值更改下拉值
- tomcat - 来自 F5 负载均衡器虚拟 IP 时,Tomcat 8.5 不服务 http 请求
- text-to-speech - 如何从 Microsoft.CognitiveServices.Speech 获取详细语音识别结果
- java - 如何在 Lagom Framework 中进行删除操作?
- python-3.x - 如何逐行读取具有匹配字符串的文件到列表中
- python-3.x - Python 中的简单 HTTP 服务器。如何从 DIR_PATH 获取文件?
- swift - 如何在使用`if let`可选展开时获取参考(swift)
- ms-access - 复制表单“数据库已处于某种状态”时出错
- bash - 如何对管道中“cat”发送的输入进行排序以使其起作用?