Search code examples
pythonpyinstaller

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


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:\Users\user_1\AppData\Local\Temp\_MEI197042\clicknium\.lib\automation\ClickniumJavaBridge-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_name\venv\Lib\site-packages\clicknium\.lib\automation\*;clicknium\.lib\automation" --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:\Users\user_1\AppData\Local\Temp\_MEIxxxxxx\clicknium\.lib\automation\ClickniumJavaBridge-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.


Solution

  • 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