Jason Baker
Jason Baker

Reputation: 198777

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

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?

Upvotes: 1

Views: 460

Answers (3)

Jason Baker
Jason Baker

Reputation: 198777

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.

Upvotes: 3

Piotr Byzia
Piotr Byzia

Reputation: 3423

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 that this point to the Python installation you want to use (main.m):

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

Upvotes: 2

pts
pts

Reputation: 87381

Try specifying the full path to the Python interpreter in the command line, something like:

/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 the environment variable PYTHONPATH set, you might have to unset it or change it.

Upvotes: 2

Related Questions