我一直在努力设置virtualenv用于django,但我一直在用pip安装virtualenv时出现问题。
jeff@jeff-HP-MacBook-Android:~/repos$ pip install virtualenv
Collecting virtualenv
Using cached virtualenv-13.1.2-py2.py3-none-any.whl
Installing collected packages: virtualenv
Exception:
Traceback (most recent call last):
File "/home/jeff/.local/lib/python2.7/site-packages/pip/basecommand.py", line 211, in main
status = self.run(options, args)
File "/home/jeff/.local/lib/python2.7/site-packages/pip/commands/install.py", line 311, in run
root=options.root_path,
File "/home/jeff/.local/lib/python2.7/site-packages/pip/req/req_set.py", line 646, in install
**kwargs
File "/home/jeff/.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/jeff/.local/lib/python2.7/site-packages/pip/req/req_install.py", line 998, in move_wheel_files
isolated=self.isolated,
File "/home/jeff/.local/lib/python2.7/site-packages/pip/wheel.py", line 339, in move_wheel_files
clobber(source, lib_dir, True)
File "/home/jeff/.local/lib/python2.7/site-packages/pip/wheel.py", line 317, in clobber
shutil.copyfile(srcfile, destfile)
File "/usr/lib/python2.7/shutil.py", line 83, in copyfile
with open(dst, 'wb') as fdst:
IOError: [Errno 13] Permission denied: '/usr/local/lib/python2.7/dist-packages/virtualenv.py'
jeff@jeff-HP-MacBook-Android:~/repos$
我能找到的最接近的答案是关于virtualenv中的权限:How to avoid "Permission denied" when using pip with virtualenv
但是我可以告诉我的问题是我的pip安装有问题,因为我显然还没有使用virtualenv。
答案 0 :(得分:7)
我认为你的pip安装没有任何问题。 virtualenv本身就是一个Python模块,默认情况下它位于/usr/local/lib/python2.7/dist-packages中,这是一个用户没有写入权限的文件夹。如果您有sudo访问权限,那么最简单的尝试就是:
sudo pip install virtualenv
一旦你完成了,你应该能够创建virtualenvs而无需使用sudo。或者,有一些说明here用于制作您自己的虚拟环境,但看起来您可能需要手动编辑它指示您下载的脚本。