PYTHONPATH and additional modules

262 views
Skip to first unread message

md

unread,
Jul 22, 2014, 5:18:37 PM7/22/14
to python_in...@googlegroups.com
Hey guys ,

I am having some trouble. I installed matplotlib using easy_install. The following runs fine in idle ...

from pyparsing import *
from pylab import *

however within Maya I get the following error...

// Error: No module named pyparsing

# Traceback (most recent call last):

# File "<maya console>", line 1, in <module>

# ImportError: No module named pyparsing //


How can I check the paths that Maya is looking for these modules in ? Here is my PYHONPATH


PYTHONPATH=%PYTHONPATH%;%MAYA_LOCATION%;c:\Python27;C:\Python27\lib;C:\Python27\Lib\site-packages


PyParsing is within C:\Python27\Lib\site-packages


Thanks .... yet again !!

md

unread,
Jul 22, 2014, 5:31:43 PM7/22/14
to python_in...@googlegroups.com
I used 

import sys
print sys.path

to check th epath inside Maya ... its huge .. I also see that Maya is reading its own python directories

what is the easiest way to clean this up ... lol

Justin Israel

unread,
Jul 22, 2014, 5:43:43 PM7/22/14
to python_in...@googlegroups.com

If you use python eggs (as opposed to normal package sub directories)  and have a bunch of them in a location, then the site/pth process will end up expanding your PYTHONPATH to have all those eggs in there.

You can control your custom Maya environment either with a wrapper to launch Maya, or from your userSetup.py in your prefs scripts location to configure the environment.

--
You received this message because you are subscribed to the Google Groups "Python Programming for Autodesk Maya" group.
To unsubscribe from this group and stop receiving emails from it, send an email to python_inside_m...@googlegroups.com.
To view this discussion on the web visit https://groups.google.com/d/msgid/python_inside_maya/19519f87-ca61-4bc2-9dd1-974c9e0d11b8%40googlegroups.com.
For more options, visit https://groups.google.com/d/optout.

md

unread,
Jul 22, 2014, 8:39:25 PM7/22/14
to python_in...@googlegroups.com
So I got the modules loading by using the following in my maya.env

PYTHONPATH=%PYTHONPATH%;%MAYA_LOCATION%;C:\Python27;C:\Python27\Lib\site-packages;C:\Python27\Lib\site-packages\dateutil;C:\Python27\Lib\site-packages\matplotlib;C:\Python27\Lib\site-packages\numpy

There has to be a better way.

Justin Israel

unread,
Jul 22, 2014, 9:10:45 PM7/22/14
to python_in...@googlegroups.com
Either userSetup,py, or a wrapper script that launches Maya?



--
You received this message because you are subscribed to the Google Groups "Python Programming for Autodesk Maya" group.
To unsubscribe from this group and stop receiving emails from it, send an email to python_inside_m...@googlegroups.com.

md

unread,
Jul 23, 2014, 10:28:04 AM7/23/14
to python_in...@googlegroups.com
I am now using a userSetup.py to set python paths.

The modules are being found, but I am running into trouble loading them.

Specifically numpy. 

As far as I know Maya  2015 uses Python 2.7. I downloaded the latest numpy for python 2.7. It installes (by default) in my C:\Python27\Lib\site-packages\numpy directory.

I dont get any errors launching maya with my new usersetup.py but when I try the import :

import numpy as np

i get this error

// Error: DLL load failed: The specified module could not be found.

# Traceback (most recent call last):

# File "<maya console>", line 1, in <module>

# File "C:\Python27\Lib\site-packages\numpy\__init__.py", line 168, in <module>

# from . import add_newdocs

# File "C:\Python27\Lib\site-packages\numpy\add_newdocs.py", line 13, in <module>

# from numpy.lib import add_newdoc

# File "C:\Python27\Lib\site-packages\numpy\lib\__init__.py", line 8, in <module>

# from .type_check import *

# File "C:\Python27\Lib\site-packages\numpy\lib\type_check.py", line 11, in <module>

# import numpy.core.numeric as _nx

# File "C:\Python27\Lib\site-packages\numpy\core\__init__.py", line 6, in <module>

# from . import multiarray

# ImportError: DLL load failed: The specified module could not be found. //


I confirmed that 'C:\\Python27\\Lib\\site-packages' is indeed in my sys.path using 'print sys.path'

Eric Thivierge

unread,
Jul 23, 2014, 10:32:58 AM7/23/14
to python_in...@googlegroups.com, md
Are you sure you got the correct version for your Python version?

import sys
print sys.version

Does that match the version of numpy you grabbed? I'm guessing the
numpy installer would check for compatibility though...

Marcus Ottosson

unread,
Jul 23, 2014, 10:46:56 AM7/23/14
to python_in...@googlegroups.com, md

On Windows, Maya is using a Python version compiled with a different compiler than the version you get from Python.org; Visual Studio 2010 as opposed to Visual Studio 2008. You’ll have to get a version of numpy compiled with 2010 if you need it to work from within Maya. You can get the version by looking at the initial text you get when launching the interpreter, e.g. this means VS2008:

Python 2.7.6 (default, Nov 10 2013, 19:24:24) [MSC v.1500 64 bit (AMD64)] on win
32
Type "help", "copyright", "credits" or "license" for more information.

MSC v.1500 means VS2008, whereas MSC v.1600 means VS2010.



--
You received this message because you are subscribed to the Google Groups "Python Programming for Autodesk Maya" group.
To unsubscribe from this group and stop receiving emails from it, send an email to python_inside_maya+unsub...@googlegroups.com.
To view this discussion on the web visit https://groups.google.com/d/msgid/python_inside_maya/53CFC78E.5070408%40hybride.com.

For more options, visit https://groups.google.com/d/optout.



--
Marcus Ottosson
konstr...@gmail.com

md

unread,
Jul 23, 2014, 11:16:52 AM7/23/14
to python_in...@googlegroups.com, acco...@mdonovan.com
When I launch my Python shell I can see that it is [MSC v.1500 64 bit (AMD64)]  

So I need to find a version of python 27 that was compiled on 2010 if I want to be safe .. and find modules compiled w/ 2010 as well ?

How does one find these ? I guess google ?

Thanks

M

On Wednesday, July 23, 2014 10:46:56 AM UTC-4, Marcus Ottosson wrote:

On Windows, Maya is using a Python version compiled with a different compiler than the version you get from Python.org; Visual Studio 2010 as opposed to Visual Studio 2008. You’ll have to get a version of numpy compiled with 2010 if you need it to work from within Maya. You can get the version by looking at the initial text you get when launching the interpreter, e.g. this means VS2008:

Python 2.7.6 (default, Nov 10 2013, 19:24:24) [MSC v.1500 64 bit (AMD64)] on win
32
Type "help", "copyright", "credits" or "license" for more information.

MSC v.1500 means VS2008, whereas MSC v.1600 means VS2010.

On 23 July 2014 15:32, Eric Thivierge <ethiv...@hybride.com> wrote:
Are you sure you got the correct version for your Python version?

import sys
print sys.version

Does that match the version of numpy you grabbed? I'm guessing the numpy installer would check for compatibility though...


--
You received this message because you are subscribed to the Google Groups "Python Programming for Autodesk Maya" group.
To unsubscribe from this group and stop receiving emails from it, send an email to python_inside_maya+unsubscribe@googlegroups.com.



--
Marcus Ottosson
konstr...@gmail.com

md

unread,
Jul 23, 2014, 11:31:58 AM7/23/14
to python_in...@googlegroups.com, acco...@mdonovan.com
I did find this bit of information on  http://www.robg3d.com/maya-windows-binaries/

  • Maya 2012 and earlier use whatever compiler Python uses.
  • Maya 2013 and 2014 use Python 2.6 compiled with VS2010. The same binaries should be compatible in Maya 2013 and 2014.
  • Maya 2015 uses Python 2.7 compiled with VS2012 Update 4.
So ... i guess this means i have to search out libraries and Python2.7  that have been recompiled using VS2012 ?

(or download visual studio and try to recompile them myself ?)

I cant spend all day looking for this stuff ... i know there are a ton of legalities, but I wish that Autodesk would have recompiled the most widely used libraries and included them with Maya.

Eric Thivierge

unread,
Jul 23, 2014, 11:34:17 AM7/23/14
to python_in...@googlegroups.com, acco...@mdonovan.com
Or just used the system's python? :)

Marcus Ottosson

unread,
Jul 23, 2014, 11:47:51 AM7/23/14
to python_in...@googlegroups.com, Michael Donovan

Or just used the system’s python? :)

I think he’s referring to importing modules within Maya.

So … i guess this means i have to search out libraries and Python2.7 that have been recompiled using VS2012 ?

Yeah, it’s quite an effort. You’ll have to maintain separate PYTHONPATHs per compiler of Python, I’m not sure there’s any way around it. As you can see, Maya’s keen on non-standard compilers and for you this means you’ll have to maintain non-standard versions of your python libraries that involve binaries.

Here’s one way you could achieve it:

win32/
  msc1500/
    numpy
  msc1600/
    numpy
darwin/
  numpy

Which is added to sys.path upon load, depending on the environment; Windows versus Linux, Maya versus non-Maya and so on.

import sys
if sys.platform == 'win32':
   if "MSC v.1500' in sys.version:
       sys.path.insert(0, 'win32/msc1500')
   if "MSC v.1600' in sys.version:
       sys.path.insert(0, 'win32/msc1600')

Thing to note thought is that this is only really relevant when your packages involve binaries; as they are platform dependent. An easier method may be to try and find pure-python equivalents of the libraries you need. In the case of numpy however I’m not sure one exists.



--
You received this message because you are subscribed to the Google Groups "Python Programming for Autodesk Maya" group.
To unsubscribe from this group and stop receiving emails from it, send an email to python_inside_maya+unsub...@googlegroups.com.
To view this discussion on the web visit https://groups.google.com/d/msgid/python_inside_maya/53CFD5EE.5040209%40hybride.com.

For more options, visit https://groups.google.com/d/optout.



--
Marcus Ottosson
konstr...@gmail.com

Justin Israel

unread,
Jul 23, 2014, 3:39:25 PM7/23/14
to python_in...@googlegroups.com, md

I have to say that Windows is the most complicated out of the platforms, when dealing with compiled python extension compatibility in Maya. 
Osx/Linux are far easier to end up with standard compiled extensions that work within Maya.

To unsubscribe from this group and stop receiving emails from it, send an email to python_inside_m...@googlegroups.com.
To view this discussion on the web visit https://groups.google.com/d/msgid/python_inside_maya/CAFRtmOCK_ze9OYPJPZrd7VJPjgK%2B9Q2EcLVdsWmR7vP2nRmdHA%40mail.gmail.com.

Marcus Ottosson

unread,
Jul 24, 2014, 7:41:33 AM7/24/14
to python_in...@googlegroups.com, md
Thanks for chipping in, Justin, but that's not really helpful.



For more options, visit https://groups.google.com/d/optout.



--
Marcus Ottosson
konstr...@gmail.com

Message has been deleted

md

unread,
Jul 24, 2014, 11:32:09 AM7/24/14
to python_in...@googlegroups.com, acco...@mdonovan.com
Thanks to all !! I feel like a little kid that has been give a key to the gun rack. ;-)
Reply all
Reply to author
Forward
0 new messages