在virtualenv

时间:2015-06-04 23:44:53

标签: python virtualenv virtualenvwrapper

修改:固定!

只需要输入.cache目录

我已尝试virtualenvwrapper docs说明,我已尝试this guy's instructions以及these ...我已尝试sudo pip uninstall virtualenv 在尝试每组指令之前,sudo pip uninstall virtualenvwrappersudo pip3 uninstall virtualenvsudo pip3 uninstall virtualenvwrapper。我看过像this one这样的其他SO帖子,但是sudo问题与我自己的问题不一样。通过这个,我的意思是我在制作virtualenv时不使用sudo,如果我尝试使用sudo pip安装包,它只会说我已经安装了包(在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

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不能正常工作?

2 个答案:

答案 0 :(得分:12)

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

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

--no-cache-dir Disable the cache.

希望将来可以帮助某人。

答案 1 :(得分:6)

您需要更改pip目录的所有者。

运行chown -R <user>:<group> /home/aweeeezy/.cache/pip