post processing on OS X with python script

Come up with a useful post-processing script? Share it here!
Post Reply
imthenachoman
Jr. Member
Jr. Member
Posts: 59
Joined: March 2nd, 2009, 10:58 am
Contact:

post processing on OS X with python script

Post by imthenachoman »

I am having trouble running a python post processing script. Right now my script is simple:

Code: Select all

#!/usr/bin/python2.6

import sys
import plistlib
Here is the error:
    'import site' failed; use -v for traceback
...(cut for brevity)...
ImportError: No module named plistlib
The program works fine when run via CLI.

I have even tried a wrapper script:

Code: Select all

#!/bin/bash

SCRIPT_DIR=`dirname "$(cd "${0%/*}" 2>/dev/null; echo "$PWD"/"${0##*/}")"`
/usr/bin/python2.6 $SCRIPT_DIR/to_iphone.py "$@"
But I get the same error.

I am on beta6 but I had the same problem with beta5.
zerointerupt
Newbie
Newbie
Posts: 2
Joined: December 19th, 2009, 5:04 am

Re: post processing on OS X with python script

Post by zerointerupt »

I'm having the same troubles with a different script.  Is it a problem with our python path?  I've checked my path in the python interpreter using sys.path and it seems to be point towards 2.6.

Does anyone have any ideas?  I've seen quite a few posts from people having this problem on their Macs but no solutions.
imthenachoman
Jr. Member
Jr. Member
Posts: 59
Joined: March 2nd, 2009, 10:58 am
Contact:

Re: post processing on OS X with python script

Post by imthenachoman »

Yeah it has something to do with the PATH that SabNZBD uses. I'm finding the path for all my modules and adding them to the path for SabNZBD.
imthenachoman
Jr. Member
Jr. Member
Posts: 59
Joined: March 2nd, 2009, 10:58 am
Contact:

Re: post processing on OS X with python script

Post by imthenachoman »

Look at my code to see how I got it to work.

http://forums.sabnzbd.org/index.php?topic=3562.msg25576
Camelot
Jr. Member
Jr. Member
Posts: 64
Joined: August 18th, 2008, 6:23 am

Re: post processing on OS X with python script

Post by Camelot »

cool. I will give your fix a try, and post back if it works for my script.

Edit: works like a charm. thanks! Been annoyed for a month about that "bug" :)
Last edited by Camelot on February 2nd, 2010, 5:34 am, edited 1 time in total.
User avatar
shypike
Administrator
Administrator
Posts: 19774
Joined: January 18th, 2008, 12:49 pm

Re: post processing on OS X with python script

Post by shypike »

It looks like this something Snow Leopards Python causes.
The app is built on Snow Leopard.
The script gets the wrong PYTHONPATH and PYTHONHOME environment variables,
the ones of the "embedded" Python.
I'm not sure we can fix this.

There is a work-around possible.
You'll need to make a wrapper script:

Code:

#!/bin/sh
unset PYTHONPATH
unset PYTHONHOME
/full-path-to-your/python-script.py $*
rAf
Moderator
Moderator
Posts: 546
Joined: April 28th, 2008, 2:35 pm
Location: France
Contact:

Re: post processing on OS X with python script

Post by rAf »

I've found another way to make it works.
Just add "-E" to your python scripts shebang like this :

Code: Select all

#!/usr/bin/python -E
No need to make a wrapper or mod sys.path anymore.
zakharm
Release Testers
Release Testers
Posts: 56
Joined: September 29th, 2008, 1:08 pm

Re: post processing on OS X with python script

Post by zakharm »

great find rAf!
Write album art post processing script
Post Reply