简体   繁体   English

使用pip安装flask时获得权限被拒绝错误

[英]Getting a permission denied error when installing flask with pip

I tried to run pip install flask on Arch Linux and I get the following error: 我试图在Arch Linux上运行pip install flask ,我收到以下错误:

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.`

What does this error mean? 这个错误是什么意思?

Use 采用

pip install --user flask

instead. 代替。

You are getting a Permission Denied error which means that you don't have access to write to a specific location. 您将收到“权限被拒绝”错误,这意味着您无权写入特定位置。

When you are using pip install flask , pip will try to install the package flask somewhere in /usr/lib/python3.6/../ . 当你使用pip install flaskpip将尝试在/usr/lib/python3.6/../ flask某处安装包装/usr/lib/python3.6/../ This directory requires root access something you don't have at the time you were running pip install flask . 这个目录需要root访问权限,当你运行pip install flask时你没有。

By using the --user flag, you are telling pip to install the package to your home directory which does not require root permissions. 通过使用--user标志,您告诉pip将软件包安装到您的主目录,该目录不需要root权限。

It's always a good practice to install Python packages using the --user flag because you are not installing that package system-wide. 使用--user标志安装Python软件包始终是一个好习惯,因为您不是在系统范围内安装该软件包。 When you use sudo pip install package_name then you are installing/upgrading a package (with dependencies) system-wide. 当您使用sudo pip install package_name您将在系统范围内安装/升级包(具有依赖项)。 Python in some systems power-up critical system components, forcing the system to install a new version of a package might break some critical system component. Python在一些系统中启动关键系统组件,迫使系统安装新版本的软件包可能会破坏一些关键的系统组件。 Usually, systems are stuck to a specific package version just to support backwards-compatibility, you might break this if you try to install it as a sudo. 通常,系统只是为了支持向后兼容而停留在特定的软件包版本上,如果您尝试将其安装为sudo,可能会破坏它。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

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