提问者:小点点

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


我正在使用ubuntu 12.04,我正在尝试pip安装虚拟环境,但突然我收到了这个错误。

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

有人知道我的案子吗?


共3个答案

匿名用户

我听说将sudopip一起使用是不安全的。

尝试将--user添加到命令的末尾,如此处所述。

pip install packageName --user

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

匿名用户

您没有Python文件夹的权限。

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

匿名用户

使用

sudo pip install virtualenv

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