11
我在稍微老一點的操作系統上運行Python,其系統Python版本爲2.6。因此,我已將2.7安裝在我的主目錄中,並使用該Python來獲取pip,並使用該pip來安裝virtualenvwrapper。所以,我有爲什麼在virtualenv中寫入/ usr/lib的pip?
$ which python pip virtaulenv virtualenvwrapper.sh
/home/user/bin/python
/home/user/bin/pip
/home/user/.local/bin/virtualenv
/home/user/.local/bin/virtualenvwrapper.sh
我使用這些工具來創建的virtualenv,並嘗試安裝模塊
$ mkvirtualenv fred
New python executable in fred/bin/python2.7.10
Also creating executable in fred/bin/python
Installing setuptools, pip, wheel...done.
virtualenvwrapper.user_scripts creating /home/user/.virtualenvs/fred/bin/predeactivate
virtualenvwrapper.user_scripts creating /home/user/.virtualenvs/fred/bin/postdeactivate
virtualenvwrapper.user_scripts creating /home/user/.virtualenvs/fred/bin/preactivate
virtualenvwrapper.user_scripts creating /home/user/.virtualenvs/fred/bin/postactivate
virtualenvwrapper.user_scripts creating /home/user/.virtualenvs/fred/bin/get_env_details
$ workon fred
$ export PYTHONPATH=/home/user/.virtualenvs/fred/lib/python2.7/site-packages
$ /home/user/.virtualenvs/fred/bin/easy_install --prefix=/home/user/.virtualenvs/fred pip
Creating /home/user/.virtualenvs/fred/lib/python2.7/site-packages/site.py
Searching for pip
Best match: pip 7.1.2
Adding pip 7.1.2 to easy-install.pth file
Installing pip script to /home/user/.virtualenvs/fred/bin
Installing pip3.4 script to /home/user/.virtualenvs/fred/bin
Installing pip3 script to /home/user/.virtualenvs/fred/bin
Using /home/user/.virtualenvs/fred/lib/python2.7/site-packages
Processing dependencies for pip
Finished processing dependencies for pip
$ which python pip
/home/user/.virtualenvs/fred/bin/python
/home/user/.virtualenvs/fred/bin/pip
$ pip install itsdangerous
Collecting itsdangerous
Installing collected packages: itsdangerous
Exception:
Traceback (most recent call last):
File "/home/user/.local/lib/python2.7/site-packages/pip/basecommand.py", line 211, in main
status = self.run(options, args)
File "/home/user/.local/lib/python2.7/site-packages/pip/commands/install.py", line 311, in run
root=options.root_path,
File "/home/user/.local/lib/python2.7/site-packages/pip/req/req_set.py", line 646, in install
**kwargs
File "/home/user/.local/lib/python2.7/site-packages/pip/req/req_install.py", line 803, in install
self.move_wheel_files(self.source_dir, root=root)
File "/home/user/.local/lib/python2.7/site-packages/pip/req/req_install.py", line 998, in move_wheel_files
isolated=self.isolated,
File "/home/user/.local/lib/python2.7/site-packages/pip/wheel.py", line 341, in move_wheel_files
clobber(source, lib_dir, True)
File "/home/user/.local/lib/python2.7/site-packages/pip/wheel.py", line 319, in clobber
shutil.copyfile(srcfile, destfile)
File "/usr/lib64/python2.7/shutil.py", line 83, in copyfile
with open(dst, 'wb') as fdst:
IOError: [Errno 13] Permission denied: '/usr/lib/python2.7/site-packages/itsdangerous.py'
爲什麼PIP試圖安裝模塊到/ usr/lib目錄?不應該將它安裝到~/.virtualenvs/fred/lib
或~/lib
?
你的'.pip/pip.conf'是什麼? – sobolevn
不一定是一種解決方案,但您可能能夠在用戶級別安裝軟件包。 'pip install --user itsdangerous' – ThorSummoner
@ThorSummoner - 因爲我需要它安裝在virtualenv中,所以不能使用'--user',而不是〜/ .local – jalanb