Error Message with Python: "OpenMaya.py line 21 DLL load failed"

Error Message with Python: "OpenMaya.py line 21 DLL load failed"

Anonymous
Not applicable
2,668 Views
4 Replies
Message 1 of 5

Error Message with Python: "OpenMaya.py line 21 DLL load failed"

Anonymous
Not applicable

Hello,

when trying to render in Krakatoa for the first time I get the following mesage:

// Error: line 1: ImportError: file S:\Maya_2015_DI\build\Release\runTime\Python\Lib\site-packages\maya\OpenMaya.py line 21: DLL load failed: The specified procedure could not be found. //
currentTime 8 ;


Can anyone shed any light on this as I don't have a clue?

Many thanks - Chris

0 Likes
2,669 Views
4 Replies
Replies (4)
Message 2 of 5

agovela
Contributor
Contributor

I'm having the same issue with importing some modules in general like: "import maya.OpenMaya as openMaya"

 

"# Error: line 1: ImportError: file S:\Maya_2015_DI\build\Release\runTime\Python\Lib\site-packages\maya\OpenMaya.py line 21: DLL load failed: The specified procedure could not be found. # "

 

 

 

Were you able to figure it out?

 

Thanks!

 

0 Likes
Message 3 of 5

Anonymous
Not applicable

Same here - just trying to change some launch scripts and when I try :

 

import maya.OpenMaya as OpenMaya


File "S:\Maya_2016_DI\build\Release\runTime\Python\Lib\site-packages\maya\Open
Maya.py", line 25, in <module>
File "S:\Maya_2016_DI\build\Release\runTime\Python\Lib\site-packages\maya\Open
Maya.py", line 21, in swig_import_helper
ImportError: DLL load failed: The specified module could not be found.

 

Anyone have any ideas?

0 Likes
Message 4 of 5

agovela
Contributor
Contributor

I think in my end, I had a python path ENV variable pointing to 2014 Maya folder. I would start there....

 

 

Hope this helps.

 

A.

 

0 Likes
Message 5 of 5

Anonymous
Not applicable

I was dealing with this error in the context of running a Maya sub process from a compiled Python application.

 

What I found was that without 'SYSTEMDRIVE': 'C:' in your os.environ, this error would happen. So when you call a subprocess from a compiled Python program, create a dictionary of the environment and pass that to the subprocess.

 

Example:

 

import getpass
import winpaths
import subprocess

processEnvironment = {
'SYSTEMROOT': '%s' % str(winpaths.get_windows()), #'C:\\windows'
'USERNAME': '%s' % getpass.getuser(), 
'PATH':'%s\\python;%s\\python\\com\\lib;%s\\python\\com\\lib\\PySide2;' % (com.forge.config.getToolRoot(), com.forge.config.getToolRoot(), com.forge.config.getToolRoot()),
'PYTHONPATH': '%s\\python;%s\\python\\com\\lib;%s\\python\\com\\lib\\PySide2' % (com.forge.config.getToolRoot(), com.forge.config.getToolRoot(), com.forge.config.getToolRoot()), 
'QT_QPA_PLATFORM_PLUGIN_PATH': '%s\\python\\com\\lib\\PySide2\\plugins\\platforms' % com.forge.config.getToolRoot(), 
'QTDIR': '%s\\python\\com\\lib\\PySide2' % com.forge.config.getToolRoot(),
'USERPROFILE': '%s' % str(winpaths.get_user_profile()), # 'C:\\Users\\userName'

'APPDATA': '%s' % str(winpaths.get_appdata()), # 'C:\\Users\\userName\\AppData\\Roaming'
'LOCALAPPDATA': '%s' % str(winpaths.get_local_appdata()), # 'C:\\Users\\userName\\AppData\\Local'
'TMP': '%s\\Temp' % str(winpaths.get_local_appdata()), # 'C:\\Users\\userName\\AppData\\Local\\Temp'
'TEMP': '%s\\Temp' % str(winpaths.get_local_appdata()), # 'C:\\Users\\userName\\AppData\\Local\\Temp'
'WINDIR': '%s' % str(winpaths.get_windows()), #'C:\\windows'
'SYSTEMDRIVE': '%s:' % str(winpaths.get_windows()).split(':')[0] # 'C:'
}

mayaProcess = subprocess.Popen(
[
mayaPyPath.replace('/', '\\\\'),
'%s/python/com/forge/maya/characterize.py' % com.forge.config.getToolRoot().replace('\\', '/'),
self._preferences.activeBridge.sourceSkeletonPath,
self._preferences.activeBridge.sourceCharacterDefinitionPath,
'sourceCharacter',
sourceOutputPath

],
env=processEnvironment,
shell=True,
stdout=subprocessLogHandle,
stderr=subprocess.STDOUT
)

mayaProcess.wait()

That totally solved the issue for me in this context. Posting it here because others may run into this.....

You can ignore all the Qt stuff in there - we are using the same PySide2 version external to Maya with Python 2.7.12 that is why those env variables are in there....