Mac OSX:无法使用Virtualenv

4
我正在尝试使用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)


你有/usr/bin/install_name_tool吗? - LaC
4个回答

4

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


1
针对OS X 10.6上由Apple提供的Python,您最好坚持使用Xcode 3(3.2.6是适用于OS X 10.6的当前版本),而不是使用Xcode 4。请参见例如https://dev59.com/3W025IYBdhLWcg3wi2mw#5944375。 - Ned Deily
1
给自己一个方便,安装brew python。使用以下命令:brew install python --framework --universal - jassinm

3

在我尝试在更新的Max OS X Lion(10.7.2)上使用virtualenv时,出现了相同的错误消息。我已经安装了XCode并通过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建立了符号链接:
 $ 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 -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.

现在完美运作了!

0

使用@gregglind虚拟环境分支的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


0

网页内容由stack overflow 提供, 点击上面的
可以查看英文原文,
原文链接