Author Topic: How to import pyd file  (Read 66 times)

Some of my python dependencies cannot be imported inside of Substance Designer.

The following script works perfectly outside of Substance Designer

Code: [Select]
import cryptography
print(cryptography)
from cryptography import hazmat
print(hazmat)
from cryptography.hazmat import bindings
print(bindings)
print(dir(bindings))
from cryptography.hazmat.bindings import _padding
print(_padding)

It outputs the following:

Code: [Select]
PS & 'C:\Program Files\Allegorithmic\Substance Designer\plugins\pythonsdk\python.exe' .\test.py
<module 'cryptography' from 'C:\\Program Files\\Allegorithmic\\Substance Designer\\plugins\\pythonsdk\\lib\\site-packages\\cryptography\\__init__.py'>
<module 'cryptography.hazmat' from 'C:\\Program Files\\Allegorithmic\\Substance Designer\\plugins\\pythonsdk\\lib\\site-packages\\cryptography\\hazmat\\__init__.py'>
<module 'cryptography.hazmat.bindings' from 'C:\\Program Files\\Allegorithmic\\Substance Designer\\plugins\\pythonsdk\\lib\\site-packages\\cryptography\\hazmat\\bindings\\__init__.py'>
<module 'cryptography.hazmat.bindings._padding' from 'C:\\Program Files\\Allegorithmic\\Substance Designer\\plugins\\pythonsdk\\lib\\site-packages\\cryptography\\hazmat\\bindings\\_padding.pyd'>

But the same code inside of Substance Designer fails:

Code: [Select]
[MSG][2]<module 'cryptography' from 'C:\\Program Files\\Allegorithmic\\Substance Designer\\plugins\\pythonsdk\\lib\\site-packages\\cryptography\\__init__.py'>
[MSG][3]<module 'cryptography.hazmat' from 'C:\\Program Files\\Allegorithmic\\Substance Designer\\plugins\\pythonsdk\\lib\\site-packages\\cryptography\\hazmat\\__init__.py'>
[MSG][4]<module 'cryptography.hazmat.bindings' from 'C:\\Program Files\\Allegorithmic\\Substance Designer\\plugins\\pythonsdk\\lib\\site-packages\\cryptography\\hazmat\\bindings\\__init__.py'>
[MSG][5]['__builtins__', '__cached__', '__doc__', '__file__', '__loader__', '__name__', '__package__', '__path__', '__spec__', 'absolute_import', 'division', 'print_function']
[ERR][6]Traceback (most recent call last):
[ERR][7]  File "<string>", line 8, in <module>
[ERR][8]ImportError
[ERR][9]:
[ERR][10]DLL load failed: Le module spécifié est introuvable.

Was dll loading completly disabled in Substance Designer ?

Hi,

DLL loading is not disabled in Designer. In fact it is used for Qt for Python and it works for other common modules like NumPy or PIL.

The DLL load failed error comes from Python itself and it is not very helpful. It usually means that either the DLL with the compiled python module or any DLL dependency of the compiled module failed to load or couldn't be found.
This error can be difficult to debug. You can try using Process Explorer to see exactly where the problem is.
Maybe there is an incompatibility between a DLL used in Designer and in the cryptography module.
That would explain why you can load it inside Python but not in Designer.

We don't ship the cryptography module with Designer. Did you install it yourself using pip or a similar tool?
It is not recommended to do this, as the installed modules could be deleted when Designer is updated.
You can instead install cryptography in another directory and use the PYTHONPATH environment variable to point to the dir where you installed it.

Est.