Johannes Saam Posted April 28, 2011 Share Posted April 28, 2011 Hey folks, i have a rather strange problem! here is a dump of my python shell: Python 2.6.4 (r264:75706, Jan 27 2010, 11:18:14) [GCC 4.1.2 20061115 (prerelease) (Debian 4.1.1-21)] on linux2 Houdini 11.0.636 hou module imported. Type "help", "copyright", "credits" or "license" for more information. >>> import os >>> os.system( 'python -V' ) So i have python 2.6.4 inside houdini, but as soon as i run python with os.system() i get a different python version, 2.5.4. here is the corresponding shell output: [johannes@xw6600_014 work_johannes]$ echo $HOUDINI_PYTHON_VERSION 2.6 [johannes@xw6600_014 work_johannes]$ Python 2.5.4 [johannes@xw6600_014 work_johannes]$ python -V Python 2.6.6 [johannes@xw6600_014 work_johannes]$ as you see i have set HOUDINI_PYTHON_VERSION and i get a print fron houdini that says 2.5.4 and the same shell uses 2.6.6. I am invoking a shell script that runs python code ( to be able to run it as sudo ). But json is not found. Its not part of that python version by default. Soo the one million dollar question is why is there A) a different python version in the python shell and the os.system() one? As the shell i started houdini from behaves well! Where does it get 2.5.4 from?! and what can I do to make sure its all consistent? Any insight into this would be greatly appreciated! Thanks so much jo Quote Link to comment Share on other sites More sharing options...
danb Posted April 29, 2011 Share Posted April 29, 2011 Python 2.6.4 (r264:75706, Jan 27 2010, 11:18:14) [GCC 4.1.2 20061115 (prerelease) (Debian 4.1.1-21)] on linux2 Houdini 11.0.636 hou module imported. Type "help", "copyright", "credits" or "license" for more information. >>> import os >>> os.system( 'python -V' ) What's the output of this from within Houdini? >>> os.system( 'which python' ) What's the output this run in your shell? % which python Quote Link to comment Share on other sites More sharing options...
Johannes Saam Posted May 1, 2011 Author Share Posted May 1, 2011 [johannes@xw6600_014 ~]$ which python /fuel/depot/public/python/2.6.6/el5_5.x86_64/bin/python [johannes@xw6600_014 ~]$ hamster [johannes@xw6600_014 ~]$ /fuel/depot/commercial/houdini/11.0.636/el5_5.x86_64/houdini11.0/python/bin/python # this is the print from the os.system() call same command. good idea! but what does that tell me? thanks! jo Quote Link to comment Share on other sites More sharing options...
danb Posted May 2, 2011 Share Posted May 2, 2011 good idea! but what does that tell me? It tells you that the python binary in your shell's path is different to the python binary in the path used by os.system() within Houdini. os.system() simply runs a command in a subshell. Just because in your example it's python doesn't matter and has nothing to do with the interpreter in Houdini itself. The same rules apply as in a terminal for which binary gets executed, and that's based on path resolution. The reason you're having a problem is because your houdini wrapper is updating the search path and instead of your centralised python binary you're finding the one that ships with Houdini (found in $HFS/python/bin). Houdini does ship with python2.5 and python2.6 interpreters but it seems that python is symlinked to 2.5. If you're trying to run Python from within Houdini's interpreter you'd be much better off using the subprocess module. If you must call out to an external Python process then I'd suggest using the full path to your sitewide binary or just call the python2.6 interpreter that ships with Houdini explictly... os.system('python2.6 -V') Hope it helps! 1 Quote Link to comment Share on other sites More sharing options...
Johannes Saam Posted May 3, 2011 Author Share Posted May 3, 2011 Ha! Thanks so much! Calling it explicitly with python2.6 did the trick! Thanks so much! Quote Link to comment Share on other sites More sharing options...
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.
Note: Your post will require moderator approval before it will be visible.