升级到Lion后如何让virtualenv工作?

时间:2012-06-23 14:47:33

标签: python osx-lion virtualenv

我刚从SnowLeapord升级到Lion,现在无法创建virtualenvs。我知道升级后有新的Python安装,没有站点包,并尝试再次安装pip和virtualenv以及升级到Xcode4但我总是得到这个错误:

~ > virtualenv --distribute env
New python executable in env/bin/python
Installing distribute........
Complete output from command /Users/jaderberg/env/bin/python -c "#!python
\"\"\"Bootstra... main(sys.argv[1:])
" --always-copy -U distribute:
Traceback (most recent call last):
File "<string>", line 23, in <module>
File "/Users/jaderberg/env/lib/python2.7/distutils/__init__.py", line 16, in <module>
exec(open(os.path.join(distutils_path, '__init__.py')).read())
IOError: [Errno 2] No such file or directory: 'System/Library/Frameworks/Python.framework/Versions/2.7/lib/python2.7/distutils/__init__.py'
----------------------------------------
...Installing distribute...done.
Traceback (most recent call last):
File "/usr/local/bin/virtualenv", line 9, in <module>
load_entry_point('virtualenv==1.7.2', 'console_scripts', 'virtualenv')()
File "/Library/Python/2.7/site-packages/virtualenv-1.7.2-py2.7.egg/virtualenv.py", line 942, in main
never_download=options.never_download)
File "/Library/Python/2.7/site-packages/virtualenv-1.7.2-py2.7.egg/virtualenv.py", line 1049, in create_environment
search_dirs=search_dirs, never_download=never_download)
File "/Library/Python/2.7/site-packages/virtualenv-1.7.2-py2.7.egg/virtualenv.py", line 603, in install_distribute
search_dirs=search_dirs, never_download=never_download)
File "/Library/Python/2.7/site-packages/virtualenv-1.7.2-py2.7.egg/virtualenv.py", line 570, in _install_req
cwd=cwd)
File "/Library/Python/2.7/site-packages/virtualenv-1.7.2-py2.7.egg/virtualenv.py", line 1020, in call_subprocess
% (cmd_desc, proc.returncode))
OSError: Command /Users/jaderberg/env/bin/python -c "#!python
\"\"\"Bootstra... main(sys.argv[1:])
" --always-copy -U distribute failed with error code 1

我是一个unix / python新手,只是无法弄清楚如何使这个工作。有任何想法吗?如果不使用--distribute标记,我会收到此错误:

~ > virtualenv env
New python executable in env/bin/python
Installing setuptools.............
  Complete output from command /Users/jaderberg/env/bin/python -c "#!python
\"\"\"Bootstra...sys.argv[1:])






" /Library/Python/2.7/...ols-0.6c11-py2.7.egg:
  Traceback (most recent call last):
  File "", line 279, in 
  File "", line 207, in main
  File "/Library/Python/2.7/site-packages/distribute-0.6.27-py2.7.egg/setuptools/__init__.py", line 2, in 
    from setuptools.extension import Extension, Library
  File "/Library/Python/2.7/site-packages/distribute-0.6.27-py2.7.egg/setuptools/extension.py", line 2, in 
    import distutils.core
  File "/Users/jaderberg/env/lib/python2.7/distutils/__init__.py", line 16, in 
    exec(open(os.path.join(distutils_path, '__init__.py')).read())
IOError: [Errno 2] No such file or directory: '/System/Library/Frameworks/Python.framework/Versions/2.7/lib/python2.7/distutils/__init__.py'
----------------------------------------
...Installing setuptools...done.
Traceback (most recent call last):
  File "/usr/local/bin/virtualenv", line 9, in 
    load_entry_point('virtualenv==1.7.2', 'console_scripts', 'virtualenv')()
  File "/Library/Python/2.7/site-packages/virtualenv-1.7.2-py2.7.egg/virtualenv.py", line 942, in main
    never_download=options.never_download)
  File "/Library/Python/2.7/site-packages/virtualenv-1.7.2-py2.7.egg/virtualenv.py", line 1052, in create_environment
    search_dirs=search_dirs, never_download=never_download)
  File "/Library/Python/2.7/site-packages/virtualenv-1.7.2-py2.7.egg/virtualenv.py", line 598, in install_setuptools
    search_dirs=search_dirs, never_download=never_download)
  File "/Library/Python/2.7/site-packages/virtualenv-1.7.2-py2.7.egg/virtualenv.py", line 570, in _install_req
    cwd=cwd)
  File "/Library/Python/2.7/site-packages/virtualenv-1.7.2-py2.7.egg/virtualenv.py", line 1020, in call_subprocess
    % (cmd_desc, proc.returncode))
OSError: Command /Users/jaderberg/env/bin/python -c "#!python
\"\"\"Bootstra...sys.argv[1:])


" /Library/Python/2.7/...ols-0.6c11-py2.7.egg failed with error code 1

3 个答案:

答案 0 :(得分:6)

事实证明,虽然我将Xcode升级到版本4,但它并不会自动安装命令行工具。我跟着这个http://blog.cingusoft.org/mac-osx-lion-virtualenv-and-could-not-call-in

基本上,安装Xcode,进入首选项,然后下载并安装“命令行工具”。它现在有效。

命令行工具也可以直接从https://developer.apple.com/downloads/index.action#

获得

答案 1 :(得分:0)

我还必须升级我的setuptools。

pip install setuptools --upgrade

答案 2 :(得分:0)

cd /usr/lib/python2.7
sudo ln -s plat-x86_64-linux-gnu/_sysconfigdata_nd.py .