macos 在 Mac OS X 上运行 Virtualenv 的问题
声明:本页面是StackOverFlow热门问题的中英对照翻译,遵循CC BY-SA 4.0协议,如果您需要使用它,必须同样遵循CC BY-SA许可,注明原文地址和作者信息,同时你必须将它归于原作者(不是我):StackOverFlow
原文地址: http://stackoverflow.com/questions/2355188/
Warning: these are provided under cc-by-sa 4.0 license. You are free to use/share it, But you must attribute it to the original authors (not me):
StackOverFlow
Problem running Virtualenv on Mac OS X
提问by Oberon Dude
I'm using virtualenv-1.4.5 on Mac OS X 10.6.2 (Xcode is installed) and Python 2.6. Here's what I get when I attempt to run a virtualenv...
我在 Mac OS X 10.6.2(安装了 Xcode)和 Python 2.6 上使用 virtualenv-1.4.5。这是我尝试运行 virtualenv 时得到的结果...
Mac-Pro:pylonsdev paul$ virtualenv --no-site-packages -v trythis
Creating trythis/lib/python2.6
Symlinking Python bootstrap modules
Symlinking trythis/lib/python2.6/_abcoll.pyc
Symlinking trythis/lib/python2.6/_abcoll.pyo
Symlinking trythis/lib/python2.6/abc.pyc
Symlinking trythis/lib/python2.6/abc.pyo
Symlinking trythis/lib/python2.6/codecs.pyc
Symlinking trythis/lib/python2.6/codecs.pyo
Symlinking trythis/lib/python2.6/config
Symlinking trythis/lib/python2.6/copy_reg.pyc
Symlinking trythis/lib/python2.6/copy_reg.pyo
Symlinking trythis/lib/python2.6/encodings
Symlinking trythis/lib/python2.6/fnmatch.pyc
Symlinking trythis/lib/python2.6/fnmatch.pyo
Symlinking trythis/lib/python2.6/genericpath.pyc
Symlinking trythis/lib/python2.6/genericpath.pyo
Symlinking trythis/lib/python2.6/lib-dynload
Symlinking trythis/lib/python2.6/linecache.pyc
Symlinking trythis/lib/python2.6/linecache.pyo
Symlinking trythis/lib/python2.6/locale.pyc
Symlinking trythis/lib/python2.6/locale.pyo
Symlinking trythis/lib/python2.6/ntpath.pyc
Symlinking trythis/lib/python2.6/ntpath.pyo
Symlinking trythis/lib/python2.6/os.pyc
Symlinking trythis/lib/python2.6/os.pyo
Symlinking trythis/lib/python2.6/posixpath.pyc
Symlinking trythis/lib/python2.6/posixpath.pyo
Symlinking trythis/lib/python2.6/re.pyc
Symlinking trythis/lib/python2.6/re.pyo
Symlinking trythis/lib/python2.6/sre.pyc
Symlinking trythis/lib/python2.6/sre.pyo
Symlinking trythis/lib/python2.6/sre_compile.pyc
Symlinking trythis/lib/python2.6/sre_compile.pyo
Symlinking trythis/lib/python2.6/sre_constants.pyc
Symlinking trythis/lib/python2.6/sre_constants.pyo
Symlinking trythis/lib/python2.6/sre_parse.pyc
Symlinking trythis/lib/python2.6/sre_parse.pyo
Symlinking trythis/lib/python2.6/stat.pyc
Symlinking trythis/lib/python2.6/stat.pyo
Symlinking trythis/lib/python2.6/types.pyc
Symlinking trythis/lib/python2.6/types.pyo
Symlinking trythis/lib/python2.6/UserDict.pyc
Symlinking trythis/lib/python2.6/UserDict.pyo
Symlinking trythis/lib/python2.6/warnings.pyc
Symlinking trythis/lib/python2.6/warnings.pyo
Creating trythis/lib/python2.6/site-packages
Writing trythis/lib/python2.6/site.py
Writing trythis/lib/python2.6/orig-prefix.txt
Writing trythis/lib/python2.6/no-global-site-packages.txt
Creating parent directories for trythis/include
Symlinking trythis/include/python2.6
Creating trythis/bin
New python executable in trythis/bin/python
Changed mode of trythis/bin/python to 0755
Symlinking trythis/.Python
Error [Errno 2] No such file or directory while executing command install_name_tool -change /System/Library/Frameworks/Pyt...ython @executable_path/../.Python trythis/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.4.5', 'console_scripts', 'virtualenv')()
File "/Library/Python/2.6/site-packages/virtualenv-1.4.5-py2.6.egg/virtualenv.py", line 529, in main
use_distribute=options.use_distribute)
File "/Library/Python/2.6/site-packages/virtualenv-1.4.5-py2.6.egg/virtualenv.py", line 612, in create_environment
site_packages=site_packages, clear=clear))
File "/Library/Python/2.6/site-packages/virtualenv-1.4.5-py2.6.egg/virtualenv.py", line 806, in install_python
py_executable])
File "/Library/Python/2.6/site-packages/virtualenv-1.4.5-py2.6.egg/virtualenv.py", line 557, 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
Any suggestions why this error is being thrown?
为什么会抛出此错误的任何建议?
采纳答案by RyanWilcox
There's also a bug with virtualenv on 10.6 See the ticket on virtualenv's bitbucket. Even if you solve the problem you're having you'll still run into another problem (I think image not found for Python.framework, but I don't remember - I didn't take any notes when I ran into this)
10.6上的 virtualenv也有一个错误,请参阅virtualenv 的 bitbucket 上的票证。即使你解决了你遇到的问题,你仍然会遇到另一个问题(我认为没有找到 Python.framework 的图像,但我不记得了 - 当我遇到这个问题时我没有做任何笔记)
I did some investigating into this and I hope the root of the problem with be resolved with Python 2.7 - certainly people know about it, and submitted a patch to CPython to fix it.
我对此进行了一些调查,我希望问题的根源可以用 Python 2.7 解决——当然人们知道它,并向 CPython 提交了一个补丁来修复它。
However, it does seem like some people have had good results with 10.6.2 and virtualenv 1.4.5... or not using the system Python anymore (macports, build-by-hand).
但是,似乎有些人使用 10.6.2 和 virtualenv 1.4.5 取得了不错的结果……或者不再使用系统 Python(macports,手动构建)。
回答by guerrerocarlos
All you really need to do is install the Xcode "Command Line Tools", there is two ways to do it:
您真正需要做的就是安装 Xcode“命令行工具”,有两种方法可以做到:
1.- If you already have Xcode installed, go to Preferences -> Downloads and select "Command Line Tools".
1.- 如果您已经安装了 Xcode,请转到首选项 -> 下载并选择“命令行工具”。
2.- Download the "Command Line Tools for Xcode" .dmg from: https://developer.apple.com/downloads.
2.- 从https://developer.apple.com/downloads下载“Xcode 命令行工具”.dmg 。
You can install Xcode using the App Store, but it will not include the "Command Line Tools" by default.
您可以使用 App Store 安装 Xcode,但默认情况下它不会包含“命令行工具”。
回答by Dwayne Bailey
Install XCode from the App Store to fix the problem. I had the same error, installed XCode, ran it after installing, and now virtualenv works.
从 App Store 安装 XCode 以解决问题。我有同样的错误,安装了 XCode,安装后运行它,现在 virtualenv 工作。
回答by Daniel Roseman
Well, the error message includes this:
好吧,错误消息包括:
you must have Apple's development tools installed
你必须安装苹果的开发工具
Do you? They're on the separate XCode disk that came with OSX.
你?它们位于 OSX 附带的单独 XCode 磁盘上。
回答by jochem
I had the same error messages trying to run virtualenv on a up-to-date Max OSX Lion installation with XCode installed.
我在尝试在安装了 XCode 的最新 Max OSX Lion 安装上运行 virtualenv 时遇到了相同的错误消息。
However: Mark hints on Mar 1 2010:
然而:马克在 2010 年 3 月 1 日的提示:
Well code says you have not installed Xcode but you say you have. What does which install_name_tool at the command line say? It should be install_name_tool -> install_name_tool == /usr/bin/install_name_tool
好吧,代码说你还没有安装 Xcode,但你说你已经安装了。命令行中的 install_name_tool 是什么意思?它应该是 install_name_tool -> install_name_tool == /usr/bin/install_name_tool
I had the same problem. I had installed the latest Xcode in Lion (10.7.2).
我有同样的问题。我在 Lion (10.7.2) 中安装了最新的 Xcode。
$ 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
I made a simlink from the /Developer/usr/bin to the /usr/bin with
我做了一个从 /Developer/usr/bin 到 /usr/bin 的 simlink
$ sudo ln -s /Developer/usr/bin/install_name_tool /usr/bin/install_name_tool
Entering the 'which' command yields:
输入'which'命令产生:
$ which install_name_tool
/usr/bin/install_name_tool
After that I did the virtualenv magic
之后我做了 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.
回答by Andrei Radulescu
There is a solution for this using @gregglind's fork of virtualenv. I answered to the same problem here: mac osx: unable to use virtualenv
有一个使用@gregglind 的virtualenv 分支的解决方案。我在这里回答了同样的问题:mac osx:无法使用 virtualenv
git clone https://github.com/gregglind/virtualenv.git
cd virtualenv
git checkout feature/install_name_tool
sudo python setup.py install
回答by fijiaaron
add install_name_tool to your path
将 install_name_tool 添加到您的路径
export PATH=$PATH:/Developer/usr/bin
导出 PATH=$PATH:/Developer/usr/bin