Hey everyone, Thank you for your insights on the sitecustomize setup.
Bare with a new comer to python here and if anyone has the time to help explain the problem I get. My intention was to just have it detect Maya's version and whether 32 or 64bit to load or not load appropriate packages. In the case of Maya 2011 NOT install our server pymel package (although with Its 1.0 release today that may be moot) [I assume inserting it before the internal version overrides it?] But to my problem :)..... It seems if I try and access anything Maya related at this early stage bad things happen :) Printing the lines Paul gave me to try when in the sitecustomize.py file gives the appropriate values I need apiVerNum = MGlobal.apiVersion() and verString = MGlobal.mayaVersion() (201100 and 2011 respectively) If I use the MGlobal to query the maya version and do a check if its Maya 2011 so we do NOT install the pymel package for that version of Maya I get the following error: from pymel.all import * > # Error: AssertionError: assert hasattr(maya.utils, 'shellLogHandler'), "If > you manually installed pymel, ensure " \: If you manually installed pymel, > ensure that pymel comes before Maya's site-packages directory on PYTHONPATH > / sys.path. See pymel docs for more info. # > If you look at the path outputs below pymel does show before the Maya packages But if I comment out the anything that calls Maya and replace it with *mayaVersion = '2011'* pymel imports just fine. The path output is identical. The Path after running the new sitecustomize.py script looks like: (Maya 2010 version) [The maya 2011 version just doenst have the bolded pymel_1.0.0rc2 Post Path: D:\pipeline_tools\python\site-packages\pyodbc-2.1.7 > Post Path: *D:\pipeline_tools\python\site-packages\pymel_1.0.0rc2* > Post Path: I:\Program Files (x86)\Autodesk\Maya2010\bin > Post Path: I:\Program Files (x86)\Autodesk\Maya2010\bin\python26.zip > Post Path: I:\Program Files (x86)\Autodesk\Maya2010\Python\DLLs > Post Path: I:\Program Files (x86)\Autodesk\Maya2010\Python\lib > Post Path: I:\Program Files (x86)\Autodesk\Maya2010\Python\lib\plat-win > Post Path: I:\Program Files (x86)\Autodesk\Maya2010\Python\lib\lib-tk > Post Path: I:\Program Files (x86)\Autodesk\Maya2010\Python > Post Path: I:\Program Files > (x86)\Autodesk\Maya2010\Python\lib\site-packages > This is the sitecustomeize.py that *doesn't* work [excuse any noob things if I am doing things the long way] > import sys > import os > import re > from maya.OpenMaya import MGlobal > > for p in sys.path: print ('Pre Path: ' + p) > > apiVerNum = MGlobal.apiVersion() > verString = MGlobal.mayaVersion() > mayaVersion = str(verString) > > path = os.environ.get ("PYTHON_SITEPACKAGES") > if(os.path.exists(path)): > sitePackages = os.listdir(path) > packagesToInsert = sitePackages[:] #duplicate the list so we can remove > any packages we don't want to insert > > for package in sitePackages: > if mayaVersion == '2011': > pymelMatch = re.match('pymel', package) > if pymelMatch: > packagesToInsert.remove(package) > > for insertPackage in packagesToInsert: > sitePath = os.path.join(path, insertPackage) > realPath = os.path.realpath(sitePath) > print '*** Inserting package: %s from path: %s' % (insertPackage, > realPath) > sys.path.insert(0,realPath) > else: > print "DEV: Site packages path does not exist in Maya.env - skipping" > > for p in sys.path: print ('Post Path: ' + p) > This is the sitecustomeize.py that *does *work [excuse any noob things if I am doing things the long way] import sys > import os > import re > #from maya.OpenMaya import MGlobal > > for p in sys.path: print ('Pre Path: ' + p) > > #apiVerNum = MGlobal.apiVersion() > #verString = MGlobal.mayaVersion() > mayaVersion = '2011' > > path = os.environ.get ("PYTHON_SITEPACKAGES") > if(os.path.exists(path)): > sitePackages = os.listdir(path) > packagesToInsert = sitePackages[:] #duplicate the list so we can remove > any packages we don't want to insert > > for package in sitePackages: > if mayaVersion == '2011': > pymelMatch = re.match('pymel', package) > if pymelMatch: > packagesToInsert.remove(package) > > for insertPackage in packagesToInsert: > sitePath = os.path.join(path, insertPackage) > realPath = os.path.realpath(sitePath) > print '*** Inserting package: %s from path: %s' % (insertPackage, > realPath) > sys.path.insert(0,realPath) > else: > print "DEV: Site packages path does not exist in Maya.env - skipping" > > for p in sys.path: print ('Post Path: ' + p) > The Maya.env variable PYTHON_SITEPACKAGES = D:\ pipeline_tools\python\site-packages\ with the following folders in D:\pipeline_tools\python\site-packages\: > pymel_1.0.0rc2 > pyodbc-2.1.7 > Anyway hopefully all that makes some sense and points the way to why it didnt work :) Dave -- http://groups.google.com/group/python_inside_maya To unsubscribe, reply using "remove me" as the subject.