How do I choose which Python installation to run in a PyObjC program?

I am using Python 2.6 more than I am using the default python Leopard installation, so I installed it as my main Python installation. But I would rather use Python as the default for the PyObjC program I am working on. Is there a way to tell me to use it instead of Python 2.6?

+1


a source to share


3 answers


Finally figured it out myself. The key to this is to create a final executable link with /System/Library/Frameworks/Python.framework instead of / Library / Frameworks / Python.framework.



+3


a source


Try giving the full path to the Python interpreter on the command line, for example:

/foo/bar/python2.6 script.py
/baz/python objcscript.py

      

You can also add a shebang to the beginning of your script (first line):



#! /foo/bar/python2.6 script.py

      

If you have an environment variable PYTHONPATH

, you may need to unset or change it.

+2


a source


AFAIR this helped me (in 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 it points to the Python installation you want to use (main.m):

    Py_SetProgramName("/usr/bin/python");

      

+2


a source







All Articles