Chỉnh sửa: CỐ ĐỊNH!Lỗi 'Quyền bị từ chối' khi sử dụng cài đặt pip trong virtualenv
Chỉ cần phải chown thư mục .cache
Tôi đã thử các virtualenvwrapper docs hướng dẫn, tôi đã cố gắng this guy's instructions cũng như these ... Tôi đã thử sudo pip uninstall virtualenv
, sudo pip uninstall virtualenvwrapper
, sudo pip3 uninstall virtualenv
, sudo pip3 uninstall virtualenvwrapper
trước khi thử mỗi bộ hướng dẫn. Tôi đã xem xét các bài viết SO khác như this one, nhưng vấn đề sudo không giống như của riêng tôi. Bằng cách này, tôi có nghĩa là tôi không sử dụng sudo khi thực hiện virtualenv, và nếu tôi cố gắng sử dụng sudo để pip cài đặt một gói, nó sẽ chỉ nói rằng tôi đã cài đặt gói (bên ngoài virtualenv).
Tôi cũng đã cố gắng làm pip install --user virtualenv(wrapper)
Dưới đây là những gì tôi đã làm:
~ $ 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/
Sau đó, tôi bổ sung thêm hai dòng sau để .bashrc của tôi: (Tôi cũng đã cố gắng thiết lập VIRTUALENVWRAPPER_PYTHON
-/usr/bin/python
)
source /usr/local/bin/virtualenvwrapper.sh
VIRTUALENVWRAPPER_PYTHON='/usr/bin/python3'
Tiếp theo tôi đã thử điều này:
~ $ 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'
Tại sao virtualenv không hoạt động?
Dường như một trong các thư mục rất sôi nổi. Sẽ không cho phép bạn ... – Zizouz212
Đảm bảo rằng bạn đã cung cấp nguồn venv trước đó, vì vậy bạn không có bất kỳ sự phụ thuộc nào vào môi trường ban đầu của mình. –
@JosephSeungJaeDollar, như 'source ~/.virtualenvs/test'? Điều này sẽ không hoạt động vì venv là một thư mục. chỉnh sửa: ý của bạn là 'nguồn ~/virtualenvs/test/bin/activate', phải không? Thpat vẫn không giúp được gì. – aweeeezy