我一直试图设置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中的权限:如何在与virtualenv一起使用pip时避免"权限被拒绝"
但是我可以告诉我的问题是我的pip安装有问题,因为我显然还没有使用virtualenv.
我不认为你的pip安装有什么问题.virtualenv本身就是一个Python模块,默认情况下它位于/usr/local/lib/python2.7/dist-packages中,这是一个用户没有写入权限的文件夹.如果您有sudo访问权限,那么最简单的方法是尝试:
sudo pip install virtualenv
一旦你完成了,你应该能够创建virtualenvs而无需使用sudo.或者,这里有说明来制作您自己的虚拟环境,但看起来您可能需要对指导您下载的脚本进行一些手动编辑.