Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

PyInstaller .exe file does nothing

After 3 days, I can't get a python program packaged into a .exe file. I've tried py2exe (which continuously missed modules), and PyInstaller.

Here's the complicated part. My program uses a lot of additional installed modules (coopr, pyomo, openpyxl, glpk, cbc, pyutilib, numpy, etc.). These in turn import all kinds of other things, and I can't track it down (the PyInstaller warning log lists 676 lines of missing or potentially unneeded modules.)

However, I've gotten (by adding imports of "missing" modules to my program) a .exe version which runs from double clicking or from the command line, without printing any error.

The problem is, the program does nothing. I have an input file which is included in the build, which my program reads in, does some (intense) calculations, and then creates a .csv output file in the same directory. It works as a .py file. My .exe does nothing.

So, if you can tell me what's wrong go ahead. If not, I'd like to know any helpful steps or ideas to try. At this point, I've exhausted the feedback I can find from the program and documentation.

like image 648
Dylan Cross Avatar asked Sep 15 '15 18:09

Dylan Cross


People also ask

Why is the .exe file created by PyInstaller not working?

The most common reason a PyInstaller package fails is that PyInstaller failed to bundle a required file. Such missing files fall into a few categories: Hidden or missing imports: Sometimes PyInstaller can't detect the import of a package or library, typically because it is imported dynamically.

Do you need Python to run a PyInstaller exe?

To your users, the app is self-contained. They do not need to install any particular version of Python or any modules. They do not need to have Python installed at all. The output of PyInstaller is specific to the active operating system and the active version of Python.


1 Answers

I just solved this problem for myself.

Make sure you do not have a folder with the same name as the script you are trying to turn into an executable.

If you already have application file sample.py as well as folder sample (that contains your other .py files, say) and you want the application to retain the name sample, you can work around this problem by renaming sample.py to sample_app.py and then invoke pyinstaller with the --name option e.g., pyinstaller --onefile --name sample sample_app.py The binary created by pyinstaller will be called sample.

like image 197
Techniquab Avatar answered Sep 23 '22 13:09

Techniquab