错误:无法创建“/usr/local/lib/python2.7/dist-packages/virtualenv_support”:权限被拒绝

声明:本页面是StackOverFlow热门问题的中英对照翻译,遵循CC BY-SA 4.0协议,如果您需要使用它,必须同样遵循CC BY-SA许可,注明原文地址和作者信息,同时你必须将它归于原作者(不是我):StackOverFlow 原文地址: http://stackoverflow.com/questions/21093002/
Warning: these are provided under cc-by-sa 4.0 license. You are free to use/share it, But you must attribute it to the original authors (not me): StackOverFlow

提示:将鼠标放在中文语句上可以显示对应的英文。显示中英文
时间:2020-08-18 22:02:53  来源:igfitidea点击:

error: could not create '/usr/local/lib/python2.7/dist-packages/virtualenv_support': Permission denied

pythonubuntu-12.04virtualenvpip

提问by gadss

I am using ubuntu 12.04 and I am trying to pip install virtualenv but suddenly I got this error.

我正在使用 ubuntu 12.04 并且我正在尝试 pip install virtualenv 但突然我收到了这个错误。

samuel@sampc:~$ pip install virtualenv
Downloading/unpacking virtualenv
  Running setup.py egg_info for package virtualenv

    warning: no previously-included files matching '*' found under directory 'docs/_templates'
    warning: no previously-included files matching '*' found under directory 'docs/_build'
Installing collected packages: virtualenv
  Running setup.py install for virtualenv
    error: could not create '/usr/local/lib/python2.7/dist-packages/virtualenv_support': Permission denied
    Complete output from command /usr/bin/python -c "import setuptools;__file__='/home/samuel/build/virtualenv/setup.py';exec(compile(open(__file__).read().replace('\r\n', '\n'), __file__, 'exec'))" install --single-version-externally-managed --record /tmp/pip-Z2v_fR-record/install-record.txt:
    running install

running build

running build_py

running install_lib

creating /usr/local/lib/python2.7/dist-packages/virtualenv_support

error: could not create '/usr/local/lib/python2.7/dist-packages/virtualenv_support': Permission denied

----------------------------------------
Command /usr/bin/python -c "import setuptools;__file__='/home/samuel/build/virtualenv/setup.py';exec(compile(open(__file__).read().replace('\r\n', '\n'), __file__, 'exec'))" install --single-version-externally-managed --record /tmp/pip-Z2v_fR-record/install-record.txt failed with error code 1
Storing complete log in /home/samuel/.pip/pip.log

Does anyone have an idea about my case?

有人知道我的案子吗?

回答by sina

you have to change permission on the mentioned path.

您必须更改上述路径的权限。

回答by Alali Ruslan

Use

sudo pip install virtualenv

Apparently you will have powers of administrator when adding "sudo" before the line... just don't forget your password.

显然,在行前添加“sudo”时,您将拥有管理员权限……只是不要忘记您的密码。

回答by arpiagar

use

sudo pip install virtualenv

You have a permission denied error. This states your current user does not have the root permissions.So run the command as a super user.

您有一个权限被拒绝错误。这表明您当前的用户没有 root 权限。因此以超级用户身份运行该命令。

回答by Awais

In the case of permission denied error, you just need to go with this command.

在权限被拒绝错误的情况下,您只需要使用此命令即可。

sudo pip install virtualenv

sudobefore the command will throw away the current user permissions error.

命令之前的sudo将丢弃当前用户权限错误。

Note:For security risks, You should read piotr comment.

注意:对于安全风险,您应该阅读 piotr 评论。

回答by falsePockets

I've heard that using sudowith pipis unsafe.

我听说使用sudowithpip是不安全的。

Try adding --userto the end of your command, as mentioned here.

尝试添加--user到您的命令的最后,提到这里

pip install packageName --user

I suspect that installing with this method means the packages are not available to other users.

我怀疑使用这种方法安装意味着其他用户无法使用这些软件包。

回答by Haochen Liu

It's because the virtual environment viarable has not been installed.

这是因为尚未安装虚拟环境 viarable。

Try this:

尝试这个:

sudo pip install virtualenv
virtualenv --python python3 env
source env/bin/activate
pip install <Package>

or

或者

sudo pip3 install virtualenv
virtualenv --python python3 env
source env/bin/activate
pip3 install <Package>

回答by Beyhan Gül

pip is not give permission so can't do pip install.Try below command.

pip 未授予权限,因此无法执行 pip install.Try 下面的命令。

apt-get install python-virtualenv

回答by user732456

You don't have permission to the Python folder.

您无权访问 Python 文件夹。

sudo chown -R $USER /usr/local/lib/python2.7

回答by Seraf

First, sudo pip install 'package-name'means nothing it will return

首先,sudo pip install 'package-name'意味着什么都不会返回

sudo: pip: command not found

You get the Permission denied, you shouldn't use pip install as root anyway. You can just install the packages into your own user like mentionned above with

您获得权限被拒绝,无论如何您都不应该以 root 身份使用 pip install。您可以像上面提到的那样将软件包安装到您自己的用户中

pip install 'package-name' --user

and it will work as you intend. If you need it in any other user just run the same command and you'll be good to go.

它会按您的意愿工作。如果您在任何其他用户中需要它,只需运行相同的命令即可。