0

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.

tomm
  • 271
  • 2
  • 14

4 Answers4

2

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

justin
  • 197
  • 6
  • I have tried it and it's kind working. I have just problem with some python modules. E.g. the tkinter is not working ("module not found") Do you maybe know how to fix it? tk should be installed with python – tomm Oct 08 '22 at 11:55
  • @tomm Do you need to package a GUI application? – Zhiwei Oct 09 '22 at 02:14
  • @Zhiwei yes. The application is using clicknium to get some data from browser. So when I am using the clicknium project packaging, as justin suggested - I have problem with tkinter. When I am using the pyinstaller - problem with clicknium .dll's – tomm Oct 09 '22 at 08:58
  • 1
    @tomm Currently the default package is the console application, we will support the gui application – Zhiwei Oct 10 '22 at 02:19
  • @Zhiwei just a question - I have finally converted my application with clicknium and Package Project as you suggested. It's working even with my tk application. The only one problem is my console window what I want to hide. Do you think, is it possible? – tomm Oct 11 '22 at 19:47
  • 1
    @tomm The problem has been fixed, the next release will be good https://thumbs2.imgbox.com/23/38/c5JiBbXW_t.gif – Zhiwei Oct 12 '22 at 08:30
  • Oh that's great! So it will be possible to prepare GUI app with no console? – tomm Oct 12 '22 at 21:29
  • 1
    @tomm yes, The project package will ask you whether you choose a console or GUI kind. – Zhiwei Oct 13 '22 at 02:26
  • That's awsome, i will refresh the clicknium release page every day :) Thank you for the information! – tomm Oct 13 '22 at 18:03
  • 1
    @tomm New version is released,https://marketplace.visualstudio.com/items/ClickCorp.clicknium/changelog – Zhiwei Oct 14 '22 at 03:59
  • Great, testing! – tomm Oct 19 '22 at 17:06
  • @Zhiwei the clicknium lib works ok, but I have found some issue. – tomm Oct 28 '22 at 23:45
  • @Zhiwei Simple code with some while True and executing "cc.edge.browsers" inside will increase memory usage. So there is something wrong. As I see you are working on the library, I have added the issue to the clicknium github. github.com/clicknium/clicknium-docs/issues/46 – tomm Oct 30 '22 at 10:00
  • @tomm thanks for the feedback, we will reproduce this issue and update about this. – Zhiwei Oct 31 '22 at 11:15
1

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)

flipSTAR
  • 579
  • 1
  • 4
  • 18
0

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
  • Sorry, I have not added the info that the error occurs when I run the exe file. So pyinstaller is creating the .exe correctly but after running the script I got error that some .dll is missing – tomm Oct 02 '22 at 14:04
0

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.

Carl Walsh
  • 6,100
  • 2
  • 46
  • 50