I use Python 2.6 more than I use Leopard's default python installation, so I have it set as my main Python installation. But I'd rather use the default Python for a PyObjC program I'm working on. Is there any way to specify to only use it instead of Python 2.6?
我使用Python 2.6比使用Leopard的默认python安装更多,所以我把它设置为我的主要Python安装。但我宁愿使用默认的Python来处理我正在研究的PyObjC程序。有没有办法指定只使用它而不是Python 2.6?
3 个解决方案
#1
Finally figured this one out myself. The key to this is to make the final executable link with /System/Library/Frameworks/Python.framework instead of /Library/Frameworks/Python.framework.
最后我自己想出了这个。关键是要使用/System/Library/Frameworks/Python.framework而不是/Library/Frameworks/Python.framework创建最终的可执行链接。
#2
Try specifying the full path to the Python interpreter in the command line, something like:
尝试在命令行中指定Python解释器的完整路径,例如:
/foo/bar/python2.6 script.py
/baz/python objcscript.py
You can also add a shebang to the beginning of your script (first line):
您还可以在脚本的开头添加一个shebang(第一行):
#! /foo/bar/python2.6 script.py
If you have the environment variable PYTHONPATH
set, you might have to unset it or change it.
如果设置了环境变量PYTHONPATH,则可能必须取消设置或更改它。
#3
AFAIR this helped me (in main.m):
AFAIR这对我有帮助(在main.m中):
NSArray *pythonPathArray = [NSArray arrayWithObjects: resourcePath, [resourcePath stringByAppendingPathComponent:@"PyObjC"], @"/System/Library/Frameworks/Python.framework/Versions/Current/Extras/lib/python/", @"/Library/Python/2.5/site-packages", nil];
Also, make sure that this point to the Python installation you want to use (main.m):
另外,请确保这一点指向您要使用的Python安装(main.m):
Py_SetProgramName("/usr/bin/python");
#1
Finally figured this one out myself. The key to this is to make the final executable link with /System/Library/Frameworks/Python.framework instead of /Library/Frameworks/Python.framework.
最后我自己想出了这个。关键是要使用/System/Library/Frameworks/Python.framework而不是/Library/Frameworks/Python.framework创建最终的可执行链接。
#2
Try specifying the full path to the Python interpreter in the command line, something like:
尝试在命令行中指定Python解释器的完整路径,例如:
/foo/bar/python2.6 script.py
/baz/python objcscript.py
You can also add a shebang to the beginning of your script (first line):
您还可以在脚本的开头添加一个shebang(第一行):
#! /foo/bar/python2.6 script.py
If you have the environment variable PYTHONPATH
set, you might have to unset it or change it.
如果设置了环境变量PYTHONPATH,则可能必须取消设置或更改它。
#3
AFAIR this helped me (in main.m):
AFAIR这对我有帮助(在main.m中):
NSArray *pythonPathArray = [NSArray arrayWithObjects: resourcePath, [resourcePath stringByAppendingPathComponent:@"PyObjC"], @"/System/Library/Frameworks/Python.framework/Versions/Current/Extras/lib/python/", @"/Library/Python/2.5/site-packages", nil];
Also, make sure that this point to the Python installation you want to use (main.m):
另外,请确保这一点指向您要使用的Python安装(main.m):
Py_SetProgramName("/usr/bin/python");