How to add missing .dll files while preparing .exe file with pyinstaller

Question:

I have just prepared simple script importing some module and printing something:

from clicknium import clicknium as cc
print(cc.edge.browsers)

So I have created the venv, installed clicknium (pip3 install clicknium==0.1.9).

After that I have prepared spec file:

pyi-makespec spec_file_name script_name.py

After running the command with created .spec file:

pyinstaller spec_file_name.spec

The pyinstaller is creating the .exe file.
After running the .exe I got an error:

System.IO.FileNotFoundException: Unable to find assembly 'C:Usersuser_1AppDataLocalTemp_MEI197042clicknium.libautomationClickniumJavaBridge-32.dll'

Of course I understand the error but I’m not sure how to fix it.

When I has some problems with missing files I have added it by using –add-data while making the spec file. But It’s not working for me with .dll files.

clicknium==0.1.9
pyinstaller==5.4.1

Update

Right now I’m using velow command to create .spec file:

pyi-makespec --onefile --add-data="C:Users...project_namevenvLibsite-packagesclicknium.libautomation*;clicknium.libautomation" --name app app.py

The error above is fixed but there is something new.
The code below causes the error:

clr.AddReference(Apath)

System.BadImageFormatException: Could not load file or assembly 'file:///C:Usersuser_1AppDataLocalTemp_MEIxxxxxxclicknium.libautomationClickniumJavaBridge-32.dll' or one of its dependencies. The module was expected to contain an assembly manifest.

So as I understand the .dll file is still not visible there and clicknium is still looking for the dll files in Temp files.

Asked By: tomm

||

Answers:

If it not work for you try using other options like one file:

pyi-makespec -F script_name.py spec_file_name

also the order need to be the script first

pyi-makespec script_name.py -n spec_file_name
Answered By: user19419589

Sometimes you have to add *.dll files to your build process in the *.spec file

Look here, there is a lot of discussion about it:
Bundling data files with PyInstaller (–onefile)

Answered By: flipSTAR

clicknium supplied package project/folder function, can generate the exe.
you can refer to this: https://www.clicknium.com/documents/tutorial/vscode/project_management

first, in vscode, run command "Clicknium: Create Project", you can select the current folder;
then, run command "Clicknium: Package Project", it will generate the exe file

Answered By: justin

When trying to debug any problem with --onefile files not being right, try switching to one-folder bundling and it is a lot easier to debug missing files.

Answered By: Carl Walsh
Categories: questions Tags: ,
Answers are sorted by their score. The answer accepted by the question owner as the best is marked with
at the top-right corner.