尝试安装virtualenv时收到一个有趣的错误:
$ pip install virtualenv
产生以下错误:
Collecting virtualenv
Using cached virtualenv-15.0.2-py2.py3-none-any.whl
Installing collected packages: virtualenv
Exception:
Traceback (most recent call last):
File "/home/matt/.local/lib/python2.7/site-packages/pip/basecommand.py", line 215, in main
status = self.run(options, args)
File "/home/matt/.local/lib/python2.7/site-packages/pip/commands/install.py", line 317, in run
prefix=options.prefix_path,
File "/home/matt/.local/lib/python2.7/site-packages/pip/req/req_set.py", line 742, in install
**kwargs
File "/home/matt/.local/lib/python2.7/site-packages/pip/req/req_install.py", line 831, in install
self.move_wheel_files(self.source_dir, root=root, prefix=prefix)
File "/home/matt/.local/lib/python2.7/site-packages/pip/req/req_install.py", line 1032, in move_wheel_files
isolated=self.isolated,
File "/home/matt/.local/lib/python2.7/site-packages/pip/wheel.py", line 346, in move_wheel_files
clobber(source, lib_dir, True)
File "/home/matt/.local/lib/python2.7/site-packages/pip/wheel.py", line 324, 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'
我想知道是否有人对此有所了解?我读到usr / bin中可能有旧版软件的引用,这是可能的,但这台计算机还处于较新的一面。最好的选择是进入并清除所有对'virtualenv'的引用(我能找到的就是这些) )?
谢谢!
答案 0 :(得分:1)
问题是您尝试将软件包安装到通常需要root权限的位置。您可以按@Vince West建议并运行sudo pip install virtualenv
,或者您可以执行pip install --user virtualenv
,这会将包安装到~/.local/lib/python<version>/site-packages
。如果你走这条路线,你可能希望确保$HOME/.local/bin
中包含$PATH
。