mac osx:无法使用virtualenv

时间:2011-07-25 17:24:09

标签: python macos virtualenv

我正在尝试使用virtualenv创建一个环境。

virtualenv test
New python executable in test/bin/python
Error [Errno 2] No such file or directory while executing command install_name_tool -change /System/Library/Fram.../Versions/2.6/Python @executable_path/../.Python test/bin/python
Could not call install_name_tool -- you must have Apple's development tools installed
Traceback (most recent call last):
  File "/usr/local/bin/virtualenv", line 8, in <module>
    load_entry_point('virtualenv==1.6.4', 'console_scripts', 'virtualenv')()
  File "/Library/Python/2.6/site-packages/virtualenv-1.6.4-py2.6.egg/virtualenv.py", line 810, in main
    never_download=options.never_download)
  File "/Library/Python/2.6/site-packages/virtualenv-1.6.4-py2.6.egg/virtualenv.py", line 901, in create_environment
    site_packages=site_packages, clear=clear))
  File "/Library/Python/2.6/site-packages/virtualenv-1.6.4-py2.6.egg/virtualenv.py", line 1166, in install_python
    py_executable])
  File "/Library/Python/2.6/site-packages/virtualenv-1.6.4-py2.6.egg/virtualenv.py", line 843, in call_subprocess
    cwd=cwd, env=env)
  File "/System/Library/Frameworks/Python.framework/Versions/2.6/lib/python2.6/subprocess.py", line 595, in __init__
  File "/System/Library/Frameworks/Python.framework/Versions/2.6/lib/python2.6/subprocess.py", line 1106, in _execute_child
OSError: [Errno 2] No such file or directory

文件夹创建正常,但缺少activate等文件。任何人? (我安装了xcode 3.2.3。运行python 2.6,osx 10.6.8)

4 个答案:

答案 0 :(得分:4)

您的开发人员工具未正确安装。我建议安装Xcode 4。

答案 1 :(得分:3)

我尝试在安装了XCode的最新Max OS X Lion(10.7.2)安装上运行virtualenv时遇到了相同的错误消息,并且使用App Store非常新。

我也错过了/ usr / bin / install_name_tool,但它在系统中。在以下代码块中使用终端。

 $ locate install_name_tool
 /Developer/Platforms/iPhoneOS.platform/Developer/usr/bin/install_name_tool
 /Developer/usr/bin/install_name_tool
 /Developer/usr/share/man/man1/install_name_tool.1

我使用

从/ Developer / usr / bin到/ usr / bin创建了一个simlink
 $ sudo ln -s /Developer/usr/bin/install_name_tool /usr/bin/install_name_tool

输入'which'命令会产生:

 $ which install_name_tool
 /usr/bin/install_name_tool

之后我做了virtualenv魔术

$ virtualenv -p python2.6 myvirtenv
Running virtualenv with interpreter /opt/local/bin/python2.6
New python executable in myvirtenv/bin/python
Installing setuptools............................done.
Installing pip...............done.

现在就像魅力一样!

答案 2 :(得分:0)

使用来自@ gregglind的前缀virtualenv:

的install_name_tool
git clone https://github.com/gregglind/virtualenv.git
cd virtualenv
git checkout feature/install_name_tool
sudo python setup.py install

致谢:macdhuibh(https://github.com/pypa/virtualenv/issues/7

答案 3 :(得分:0)

从这里获取XCode命令行工具:

https://developer.apple.com/downloads/index.action?name=for%20Xcode%20-#

我刚刚安装了新的Lion,并从App Store安装了XCode - 这些没有同时安装,现在我需要单独安装...