我通过以下指南安装了Python 2.7.6:http://hackercodex.com/guide/python-development-environment-on-mac-osx/。但是,当我跑:
$ virtualenv test
我得到以下输出:
Traceback (most recent call last):
File "/usr/local/bin/virtualenv", line 9, in <module>
load_entry_point('virtualenv==1.11', 'console_scripts', 'virtualenv')()
File "/usr/local/Cellar/python/2.7.6/Frameworks/Python.framework/Versions/2.7/lib/python2.7/site-packages/virtualenv.py", line 820, in main
symlink=options.symlink)
File "/usr/local/Cellar/python/2.7.6/Frameworks/Python.framework/Versions/2.7/lib/python2.7/site-packages/virtualenv.py", line 980, in create_environment
site_packages=site_packages, clear=clear, symlink=symlink))
File "/usr/local/Cellar/python/2.7.6/Frameworks/Python.framework/Versions/2.7/lib/python2.7/site-packages/virtualenv.py", line 1176, in install_python
copy_required_modules(home_dir, symlink)
File "/usr/local/Cellar/python/2.7.6/Frameworks/Python.framework/Versions/2.7/lib/python2.7/site-packages/virtualenv.py", line 1114, in copy_required_modules
dst_filename = change_prefix(filename, dst_prefix)
File "/usr/local/Cellar/python/2.7.6/Frameworks/Python.framework/Versions/2.7/lib/python2.7/site-packages/virtualenv.py", line 1079, in change_prefix
(filename, prefixes)
AssertionError: Filename /System/Library/Frameworks/Python.framework/Versions/2.7/lib/python2.7/lib-dynload/readline.so does not start with any of these prefixes: ['/usr/local/Cellar/python/2.7.6/Frameworks/Python.framework/Versions/2.7/Extras/lib/python', '/usr/local/Cellar/python/2.7.6/Frameworks/Python.framework/Versions/2.7', '/Users/Charlie/Library/Python/2.7/lib/python/site-packages', '/Users/Charlie/.local/lib/python/2.7/site-packages', '/Users/Charlie/Library/Python/2.7/site-packages', '/Library/Python/2.7/site-packages']
似乎virtualenv正在抓取System python而不是Homebrew Python 2.7.6,但我无法弄清楚原因。
非常感谢任何帮助!
答案 0 :(得分:0)
作为一种解决方法,您可以指定用于virtualenv的Python解释器:
virtualenv test -p /usr/local/bin/python
答案 1 :(得分:-2)
我用它来安装它:
$ sudo pip install virtualenv
我在某处读过你可能需要使用sudo强制你的机器。 我保证不再使用它了。