I am trying to create a standalone exe from python code using nuitka. Its a rather sizable program with several libraries including for instance PyQt5.
I have created the exe using:python -m nuitka --standalone --follow-imports --enable-plugin=qt-plugins --enable-plugin=numpy --python-flag=no_site --mingw64 rs_main.py
I have also tried without the --mingw64 and --python-flag=no_site flags but they all give me the same error when I try to execute the resulting exe:
ImportError: LoadLibraryEx 'D:\... ...\rs_main.dist\PyQt5\QtWidgets.pyd' failed: The specified procedure could not be found.
I checked and the file does exist in the correct location.
The compiling itself gives me some warnings but no errors.
Online I found my problem here: https://github.com/Nuitka/Nuitka/issues/73 but to be honest I do not fully understand their journey towards the solution and as I think I understand it should be solved in my version of nuitka which is 0.6.6. On top of that I am running python 3.7.3 on a windows 10 machine.
Hopefully someone can explain me the solution in the referenced link or offer one of their own. thanks in advance.
So this is not really an answer to my question, but if anyone comes across this question, maybe my solution is good enough for them as well.
So although I know it does not do the same as Nuitka I was finally able to create a standalone exe using pyinstaller including some flags such as --hidden-imports and add the path to Qt but I found the feedback of pyinstaller to be rather understandable.
So maybe if you have the same problem as me, this might be a different approach for you as well.
Related
I tried to create an executable file in Windows from a kivy project with PyInstaller, and even though it appears to have been successfully created, when I try to run it, I get this
What could cause this? I'm relatively new to kivy, and any help will be much appreciated
well, I actually figured it out myself. Though I don't think that my solution is in any way elegant and it might cause some other problems in the future, but i just edited the pyi_rth_pkgutil.py from PyInstaller package directory (how it is now, how it used to be) and reran the pyinstaller package creation script. It just worked after that
Recently I have written a simple software in python and now I would like to share it with some people, but the problem is that they don't use python on their computer. Because of that an executable program could help me a lot and I tried to do it by using the package Pyinstaller with the following syntax:
pyinstaller --onefile -w program.py
After doing that three new folders was created and I found the executable file inside the dist folder but it doesn't work. When I clicked twice a error message showed up
Error message
Could anyone please tell why it happens and how I can work around this situation ? And also if you have another idea about how to convert .py to .exe besides using the Pyinstaller it would help me so much as well. I'm using python 3.8
Thanks
What error does it give you?
I haven't used Pyinstaller, but I've had success with auto-pye-to-exe as an alternative.
PyInstaller does not compile Python code into binary code. It just bundles your code into one installable exe file. So it does not improve the performance or code privacy.
Better option is to use CXFreeze or Nuitka. I personally prefer to use Nuitka because it worked in most cases where CXFreeze could not deal with.
Simply install Nuitka using pip or conda command. The documentation itself is quite good to start with.
I have a python project that has the following structure:
I am using the following for compilation, python -m nuitka --follow-imports --standalone C:\Users\probat\Documents\main.py
The project is being compiled as a standalone executeable so I also need to include Sub-Directory and also its contents (rules.txt and settings.ini) - these are not being included currently. I know I am obviously in fault here but after reading the user documentation and searching everywhere I failed to find a solution. I tried using --include-plugin-directory but that didn't work. I may not be using it correctly or I am wrong for using it. Any help is appreciated.
FWIW I just copy the folder and its contents after the compilation is done. This is part of the workflow. I did the same with PyInstaller, so it does not seem awful to me.
I was wondering if anyone has any success in creating a stand alone executable using pyinstaller with a script that has enthought imports. I have been trying to do this for a couple of days now, however I keep getting an import error. Through some digging around I believe that I might need to add some hidden import and create my own hooks. However I have not heard of anyone having any success with this, so I thought I would ask here and see if anyone might have some experience with this situation.
I had been trying to build a stand alone exe of my python app which uses matplotlib (one of the components of enthought) and was having lots of trouble getting it to work. Finally found a bug post (http://www.pyinstaller.org/ticket/651) on pyinstaller site that told me that it was a bug in pyinstaller. I followed the reference in that post to download the fixed version of pyinstaller at ​https://github.com/pyinstaller/pyinstaller/pull/61
Now my build to stand alone exe works fine. I bet you were experiencing the same problem as me. see... Building python pylab/matplotlib exe using pyinstaller
I just created an exe with cx_Freeze and proudly handed it over to a co-worker.....and it promptly crashed ("The application was unable to start correctly") I was curious to know if he must have python already installed and ready to go when he runs my exe or if it is something else that I should be worried about. (If that is the case, I will do some more research)
I am using Python 2.7 64 bit, Wxpython, and Cx_Freeze 4.2.7
UPDATE:
So I have found that a download of Python 2.7 DOES indeed fix the problem--but this is not what I really want. I have heard that with the correct options selected in the setup.py script that I can truly create a stand alone--Does ANYONE know about how I could do this? Filesize is no object.
The purpose of cx_Freeze is so that the user doesn't need Python installed. But sometimes there might be some DLL dependencies that aren't sorted out automatically by cx_Freeze. For one example, see my recent question and answer for "ImportError: DLL load failed when importing win32clipboard in application frozen with cx_Freeze".
But if you're getting the message "The application was unable to start correctly", then that sounds as though the problem is some implicit-linking DLL dependency. Try using Dependency Walker to track down which DLL is missing. Let us know your results.
No, he doesn't need to have Python installed - cx_Freeze should copy a Python DLL into the build folder. Make sure that all the files in the build folder are still with the EXE when you run it.
However, it might be necessary for him to install the Microsoft 'Visual C++ redistributable' that Python requires. I don't think cx_Freeze can automatically include that, for legal reasons (but I am not a lawyer, and I'm happy to be proved wrong). The details are in the documentation:
http://cx_freeze.readthedocs.org/en/latest/overview.html#microsoft-visual-c-2008-redistributable-package
Or there may be some other problem with the bundling for your application. I don't know what would cause that error message.