在 virtualenv 中使用 pip install 时出现“权限被拒绝"错误 [英] 'Permission denied' error when using pip install in virtualenv

查看:37
本文介绍了在 virtualenv 中使用 pip install 时出现“权限被拒绝"错误的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

已修复!

只需要 chown .cache 目录

Just had to chown the .cache directory

我已经尝试了 virtualenvwrapper docs 说明,我已经尝试了 这个人的说明 以及 这些...我试过 sudo pip uninstall virtualenv, sudo pip uninstall virtualenvwrapper, sudo pip3 uninstall virtualenv, sudo pip3 uninstall virtualenvwrapper 在尝试每组指令之前.我看过其他 SO 帖子,例如 这个,但 sudo 问题与我自己的不同.我的意思是我在制作 virtualenv 时不使用 sudo,如果我尝试使用 sudo pip install 一个包,它只会说我已经安装了这个包(在 virtualenv 之外).

I've tried the virtualenvwrapper docs instructions, I've tried this guy's instructions as well as these...I've tried sudo pip uninstall virtualenv , sudo pip uninstall virtualenvwrapper, sudo pip3 uninstall virtualenv, sudo pip3 uninstall virtualenvwrapper before attempting each set of instructions. I've looked at other SO posts like this one, but the sudo issue isn't the same as my own. By this, I mean that I don't use sudo when making the virtualenv, and if I try to use sudo to pip install a package, it'll just say that I've already installed the package (outside of the virtualenv).

我也试过 pip install --user virtualenv(wrapper)

这是我所做的:

~ $ sudo pip3 install virtualenv
Downloading/unpacking virtualenv
  Downloading virtualenv-13.0.3-py2.py3-none-any.whl (1.7MB): 1.7MB downloaded
Installing collected packages: virtualenv
Successfully installed virtualenv
Cleaning up...
~ $ mkdir ~/.virtualenvs
~ $ sudo pip3 install virtualenvwrapper
Downloading/unpacking virtualenvwrapper
  Downloading virtualenvwrapper-4.5.1-py2.py3-none-any.whl
Requirement already satisfied (use --upgrade to upgrade): virtualenv-clone in /usr/local/lib/python3.4/dist-packages (from virtualenvwrapper)
Requirement already satisfied (use --upgrade to upgrade): stevedore in /usr/local/lib/python3.4/dist-packages (from virtualenvwrapper)
Requirement already satisfied (use --upgrade to upgrade): virtualenv in /usr/local/lib/python3.4/dist-packages (from virtualenvwrapper)
Installing collected packages: virtualenvwrapper
Successfully installed virtualenvwrapper
Cleaning up...
~ $ export WORKON_HOME=~/.virtualenvs/

然后我将这两行添加到我的 .bashrc 中:(我也尝试将 VIRTUALENVWRAPPER_PYTHON 设置为 /usr/bin/python)

Then I added these two lines to my .bashrc: (I also tried setting VIRTUALENVWRAPPER_PYTHON to /usr/bin/python)

source /usr/local/bin/virtualenvwrapper.sh
VIRTUALENVWRAPPER_PYTHON='/usr/bin/python3'

接下来我尝试了这个:

~ $ mkvirtualenv test
New python executable in test/bin/python
Installing setuptools, pip, wheel...done.
(test)~ $ pip install numpy
Collecting numpy
  Using cached numpy-1.9.2.tar.gz
Building wheels for collected packages: numpy
Exception:
Traceback (most recent call last):
  File "/home/aweeeezy/.virtualenvs/test/local/lib/python2.7/site-packages/pip/basecommand.py", line 223, in main
    status = self.run(options, args)
  File "/home/aweeeezy/.virtualenvs/test/local/lib/python2.7/site-packages/pip/commands/install.py", line 291, in run
    wb.build(autobuilding=True)
  File "/home/aweeeezy/.virtualenvs/test/local/lib/python2.7/site-packages/pip/wheel.py", line 754, in build
    ensure_dir(output_dir)
  File "/home/aweeeezy/.virtualenvs/test/local/lib/python2.7/site-packages/pip/utils/__init__.py", line 70, in ensure_dir
    os.makedirs(path)
  File "/home/aweeeezy/.virtualenvs/test/lib/python2.7/os.py", line 150, in makedirs
    makedirs(head, mode)
  File "/home/aweeeezy/.virtualenvs/test/lib/python2.7/os.py", line 150, in makedirs
    makedirs(head, mode)
  File "/home/aweeeezy/.virtualenvs/test/lib/python2.7/os.py", line 150, in makedirs
    makedirs(head, mode)
  File "/home/aweeeezy/.virtualenvs/test/lib/python2.7/os.py", line 157, in makedirs
    mkdir(name, mode)
OSError: [Errno 13] Permission denied: '/home/aweeeezy/.cache/pip/wheels/4b'

为什么 virtualenv 不能正常工作?

Why can't virtualenv just work?

推荐答案

我认为如果你这样做 pip install numpy --no-cache-dir 它会起作用.

I think that if you do that pip install numpy --no-cache-dir it will work.

如果你运行 pip --help 你会发现:

If you run pip --help you will find:

--no-cache-dir 禁用缓存.

希望它可以在未来对某人有所帮助.

Hope that it can help to someone in the future.

这篇关于在 virtualenv 中使用 pip install 时出现“权限被拒绝"错误的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
相关文章
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆