From: "Mr. Daniel Browne" <dbrowne@(email surpressed)>
Subject: Re: CentOS 6 Python error
   Date: Tue, 12 Mar 2013 17:26:58 -0400
Msg# 2301
View Complete Thread (19 articles) | All Threads
Last Next
I'll try the unset method; actually that is what Maya is supposed to be doing for you but seeming isn't. Maya2012 for instance sets PYTHONHOME to /u/mayabld/Python-2.6.4/pybuild


On Mar 12, 2013, at 2:17 PM, Greg Ercolano wrote:

[posted to rush.general]

On 03/12/13 13:51, Mr. Daniel Browne wrote:
> The solution I ultimately found was to set:
> export PYTHONHOME=/usr/autodesk/maya2013-x64

I see.. so it sounds like just that variable was the problem.

But, hmm, isn't that telling the OS's version of python
to use autodesk's version of python, and thus a potential
for crashing python due to possibly incompatible modules?

I think it'd be safer to simply unset the PYTHONHOME variable
so that the OS's python uses its own defaults, e.g.

	os.system("unset PYTHONHOME; python /your/script.py")

Or, using the longer form technique I wrote earlier, the only
benefit being it should work across platforms, and can be expanded
to handle other variables if, for instance, the Windows version of
python has other settings that are needed:

---- snip
import os
def MySystem(cmd):
   # SAVE OLD PYTHONHOME
   if os.environ.has_key("PYTHONHOME"): phsave = os.environ["PYTHONHOME"]
   else:                                phsave = None

   # CHANGE TO WHAT OS WANTS
   if os.environ.has_key("PYTHONHOME"): del os.environ["PYTHONHOME"]

   # INVOKE UNIX COMMAND
   os.system(cmd)

   # RESTORE PYTHONPATH
   if phsave != None: os.environ["PYTHONHOME"] = phsave
---- snip

So if you define that inside maya's python environment,
you can then run unix commands with:

	MySystem(your_unix_command)

..and external calls to python will be protected from maya's PYTHONHOME.

-- 
Greg Ercolano, erco@(email surpressed)
Seriss Corporation
Rush Render Queue, http://seriss.com/rush/

Tel: (Tel# suppressed)ext.23
Fax: (Tel# suppressed)
Cel: (Tel# suppressed)


----------
Dan "Doc" Browne
System Administrator
Evil Eye Pictures

dbrowne@(email surpressed)
Office: (415) 777-0666 x105


Last Next