在Mac OS X上使用brew安装的Python 2.7创建virtualenv时,我遇到了以下错误:
我看到这里经常会有类似的问题(例如这里),但是被赞的答案似乎推荐使用
请注意,我已经按照这个页面上的建议进行了操作:在Mac OS X上有效地使用Python。
我该如何解决这个问题(不使用sudo)?
Could not install packages due to an EnvironmentError:
[Errno 13] Permission denied: '/lib'
完整输出:
▶ virtualenv ./virtualenv
New python executable in /Users/alexharvey/git/home/sam-test/virtualenv/bin/python2.7
Also creating executable in /Users/alexharvey/git/home/sam-test/virtualenv/bin/python
Installing setuptools, pip, wheel...
Complete output from command /Users/alexharvey/gi...ualenv/bin/python2.7 - setuptools pip wheel:
Looking in links: /usr/local/lib/python2.7/site-packages, /usr/local/lib/python2.7/site-packages/virtualenv_support, /usr/local/lib/python2.7/site-packages/virtualen
v_support
Collecting setuptools
Using cached https://files.pythonhosted.org/packages/37/06/754589caf971b0d2d48f151c2586f62902d93dc908e2fd9b9b9f6aa3c9dd/setuptools-40.6.3-py2.py3-none-any.whl
Collecting pip
Collecting wheel
Using cached https://files.pythonhosted.org/packages/ff/47/1dfa4795e24fd6f93d5d58602dd716c3f101cfd5a77cd9acbe519b44a0a9/wheel-0.32.3-py2.py3-none-any.whl
Installing collected packages: setuptools, pip, wheel
Could not install packages due to an EnvironmentError: [Errno 13] Permission denied: '/lib'
Consider using the `--user` option or check the permissions.
----------------------------------------
...Installing setuptools, pip, wheel...done.
Traceback (most recent call last):
File "/usr/local/bin/virtualenv", line 11, in <module>
sys.exit(main())
File "/usr/local/lib/python2.7/site-packages/virtualenv.py", line 762, in main
symlink=options.symlink,
File "/usr/local/lib/python2.7/site-packages/virtualenv.py", line 1015, in create_environment
install_wheel(to_install, py_executable, search_dirs, download=download)
File "/usr/local/lib/python2.7/site-packages/virtualenv.py", line 968, in install_wheel
call_subprocess(cmd, show_stdout=False, extra_env=env, stdin=SCRIPT)
File "/usr/local/lib/python2.7/site-packages/virtualenv.py", line 854, in call_subprocess
raise OSError("Command {} failed with error code {}".format(cmd_desc, proc.returncode))
OSError: Command /Users/alexharvey/gi...ualenv/bin/python2.7 - setuptools pip wheel failed with error code 1
我看到这里经常会有类似的问题(例如这里),但是被赞的答案似乎推荐使用
sudo
,这显然是错误的。请注意,我已经按照这个页面上的建议进行了操作:在Mac OS X上有效地使用Python。
我该如何解决这个问题(不使用sudo)?
~/.pydistutils.cfg
文件。很可能是install_lib
键的问题。 - phd