Hi,
I have a multi-file/folder project developed with python 3.12/pycharm running on win11.
I build a onefile exe with pyinstaller with the following command (pyinstaller 6.8.0):
pyinstaller --onefile IO_Analysis.py --add-data "SIOT_2019.xlsx;." --add-data "Results;." --add-data "src;." --add-data "Temp_Results;." --add-data "Manual;."
If I run the exe from the original pc, either from the
HD or from a USB drive, it works fine. If a move the set of files/folders in a
different pc (win 10 without python/pycharm installation) either in the HD ot
in the USB drive, the exe works only partially: it finds the pdf manual or the
xls input file but gives the error in the object if I ask for some calculation.
the call for 'numpy' is not in the main file (IO_Analysis.py) but in all the
files in the 'src' folder.
To try to solve, I have tested the building of the exe with some additional variants: i) adding the import of numpy in the main file; ii) adding the ‘--hidden-import’ option; iii) adding the ‘--paths’ option; iv) updating to the latest version of python and modules and using a new virtual environment via a ‘requirements.txt’ file, but nothing changed.
In addition, even if the “warning” text file reports some missing modules, it does not mention ‘numpy’.
Any idea of the possible solution to fix the problem?
Thank you
Below the log of the building.
If I’m reading this right, you’ve got raw .py scripts in the src folder and presumably you’re running them as subprocesses using something akin to subprocess.run(["python", "src/IO_Analysis.py"]) or possibly something involving exec()? So you’re giving code to PyInstaller as data files so it has no idea that it needs to scan them for dependencies and you’re invoking that code using a random Python interpreter instead of the one PyInstaller collected so even if PyInstaller did know to collect numpy, you wouldn’t be able to use it anyway.
I suggest that you stop trying to structure your code like a C++ project. Move everything out of src and into the top level of your project then use import IO_Analysis; IO_Analysis.do_something() instead of whatever you're using to invoke the other scripts. Or better yet, learn how to properly structure Python projects.
Knowing the math behind the program, I asked ChatGPT to translate it into python code.
--
You received this message because you are subscribed to the Google Groups "PyInstaller" group.
To unsubscribe from this group and stop receiving emails from it, send an email to pyinstaller...@googlegroups.com.
To view this discussion on the web visit https://groups.google.com/d/msgid/pyinstaller/ee0037ed-4bec-4e68-bb2e-1b5f6770707dn%40googlegroups.com.
I’m an economist not a programmer and I’m perfectly aware that my code is far from being optimized. I had some python courses online but they rarely go beyond the “Hello world” stuff. On the other hand, with hundreds of trial and error I was able to get a quite complex (for me) project which does exactly what it was supposed to do. What I can’t manage is to create a python free exe with pyinstaller. In addition I see that the “ModuleNotFoundError” is quite common…not only among economists.
@bwoodsend If you have the authority to throw me out of the forum then do it, otherwise I suggest you to not waste your time just ignoring my questions.
@Chris Barker the reason I joined the forum was indeed to look for help from human intelligence, not to stimulate the acrimony against the AI which is, at the end of the day, a product of programmers.
Any additional hint will be appreciated.To view this discussion on the web visit https://groups.google.com/d/msgid/pyinstaller/3a1484e4-1d7a-4423-933b-a127a7780cd2n%40googlegroups.com.