I'm packaging a project with PyInstaller on different ubuntu machines. On some of them, when executing the generated project, it throws this error:
File "~/PyInstaller-2.1/proj/build/proj/out00-PYZ.pyz/Crypto.Random", line 28, in ImportError: cannot import name OSRNG
However the import works perfectly ok in python console and I can execute the project without packaging it.
I've tried uninstalling and reinstalling pycrypto without success, I've also tried adding a specific
from Crypto.Random import OSRNG
to the main file just so PyInstaller would pick it up.
I've solved it by adding Crypto directory tree to spec file
I get the path with this function:
And then substitute in spec file:
I got it working by replacing pycrypto / pycryptodome with
pycryptodomex
. Sharing a link to the already posted answer: https://stackoverflow.com/a/50009769/4355695I was able to solve the problem with hithwen's recipe, but with a slightly different
.spec
file. I'll leave it here for reference for everyone.