Pyinstaller does not create functional executable with pdfrw

318 Views Asked by At

I'm trying to create an executable file using pyinstaller, but it crashes immediately upon launching that executable. It should be noted that the program works perfectly fine inside of PyCharm. I've narrowed it down to only one line of code that causes it to error using another python file - if the file contains '''import pdfrw''' it will crash immediately upon launching the executable file created by pyinstaller.

I've tried the following commands from a command prompt running in administrator mode, all of which give that same result (this is after changing the directory to where the .py file is located):

pyinstaller "compiling test.py"

pyinstaller --onefile "compiling test.py"

pyinstaller --onedir "compiling test.py"

Using a try/except clause around the import statement, I'm able to see the error message before it closes the executable, and it says:

Cannot load native module 'Crypto.Cipher._raw_ecb': Trying '_raw_ecb.cp36-win_amd64.pyd': cannot load library 'C:\Users\KYLE~1.AFF\AppData\Local\Temp_MEI534042\Crypto\Util..\Cipher_raw_ecb.cp36-win_amd64.pyd': error 0x7e. Additionally, ctypes.util.find_library() did not manage to locate a library called 'C:\Users\KYLE~1.AFF\AppData\Local\Temp\_MEI534042\Crypto\Util\..\Cipher\_raw_ecb.cp36-win_amd64.pyd', Trying '_raw_ecb.pyd': cannot load library 'C:\Users\KYLE~1.AFF\AppData\Local\Temp_MEI534042\Crypto\Util..\Cipher_raw_ecb.pyd': error 0x7e. Additionally, ctypes.util.find_library() did not manage to locate a library called 'C:\Users\KYLE~1.AFF\AppData\Local\Temp\_MEI534042\Crypto\Util\..\Cipher\_raw_ecb.pyd'

Is there a way I can modify the spec file to make the file correctly (or another solution)? I found something similar when I needed to make an executable with python-docx (and I will most likely need to do this for this program as well, as the original python program I'm trying to make an executable uses python-docx as well as pdfrw): PyInstaller and python-docx module do not work together

Thanks for your help in advance.

1

There are 1 best solutions below

1
On

So I just found a solution to this! It tipped me off when it was going down a user path named \KYLE~1.AFF\ because that user shouldn't exist, though somehow it got created. After removing that user file, I upgraded pyinstaller via pip install --upgrade pyinstaller, and it uninstalled version 3.3.1, and installed version 3.6, and now it works fine. So possibly it was the new version, but I'm guessing it was more likely the fresh install after I removed the user directory that shouldn't have existed. Not sure why it only errored out with that one library though.