I have a tiny (70 lines) python script and I need an executable which includes all the dependencies of the script. It should be usable on windows, where python-magic is only usable in connection with cygwin.
Now I've tried to use Nuitka, which gives me a 6MB executable, however it's not executable on windows, as it states it's not a valid executable, without any further information on why it's not.
Then I've been told to try cx_freeze, which I'm unable to install. Pip states my python version is incompatible. (tried it with pip and pip3 and python is installed..)
How could I get an executable for windows, including all dependencies from my python script written on a Unix system.
Windows system: Windows 8.1 64bit
Unix system: Debian Testing; Python 2.7 and 3.4 installed
I'm using python 2.7 on windows 8.1 and pyinstaller works perfectly fine.
If you want to compile an exe file which can be ported without any DLL files or anything you should use the following pyinstaller command:
python pyinstaller.py --onefile your_script_file.py
Try Pyinstaller, it is very useful to make any executable. And If you need a windows executable you have to compile it on Windows!
Related
I use pyinstaller or cx_Freeze whenever I want my Python file to convert it into a .exe package, but the problem is, my PC is 64-bit, and if I make that application, it only runs on a 64-bit PC, that's why I want to know, is there a way to develop 32-bit applications on a 64-bit PC using any module or anything? Please I really need an answer!
Download, install a 32-bit version of python and use that instead of the 64 bit python that you are using.
After installing both a 32 bit and 64 bit version of Python try running the following command to create the required exe distributable.
python -m pyinstaller {args}
Or it can be
python3.5 -m pyinstaller {args}
I'm unable to use py2app to build a python application which contains the pillow package. I'm using:
Mac OSX El Capitan (10.11.16)
Python 3.7.3 (Installed via Homebrew)
Pillow 6.0.0
py2app 0.19
macholib 1.11
The script works fine when called from the command line and the py2app bundle works fine if compiled in alias mode python3 setup.py py2app -A
But, when I try to compile a standalone bundle using:
python3 setup.py py2app --packages=PIL
I get the following error message:
ValueError: New Mach-O header is too large to relocate in '/Users/RG/Library/Mobile Documents/com~apple~CloudDocs/iHal/Code/QuotesApp/dist/Quotes.app/Contents/Resources/lib/python3.7/PIL/.dylibs/liblcms2.2.dylib' (new size=1688, max size=1680, delta=48)
I've been searching but have had no luck finding help with this issue, is it possible it's an El Capitan (OSX 10.11.16) issue?
my system specs:
Mac OSX Mojave (10.14.15)
Python 3.7.4 (python.org)
Pillow 6.1.0
py2app 0.19
macholib 1.11
I had the same issues as you. The reason why it fails is that the library is wrong compiled. I figured out two solutions.
On my system the library is located at: /Library/Frameworks/Python.framework/Versions/3.7/lib/python3.7/site-packages/PIL/.dylibs/
If you do not use color management in your project you can delete the library "liblcms2.2.dylib". Now you can run py2app and it will build.
The second solution is more work and the way I use it in my project.
First, you need Xcode because we have to recompile the "littlecms" library.
Xcode is around 6gb and you get it from the Apple Appstore. On my system have the version 10.2.1.
Download the library littlecms in version 2.2: https://www.littlecms.com/
You will be redirected to SourceForge:
https://sourceforge.net/projects/lcms/files/lcms/2.2/
Download one of these files: lcms2-2.2.zip or lcms2-2.2.tar.gz and extract it on your system.
The library source comes with the Xcode project file and you will find in Projects/mac.
If you are familiar with the terminal you can build it without the Xcode GUI. In this case, go into the extracted folder of littlecms and type following commands.
./configure
make
make check
If the last command(make check) runs fine the library is ready for deployment.
You will find the compiled library in the folder: src/.libs/.
Replace the library which comes with the PIL package with your compiled library.
Finally, run py2app to build your project.
If this is not working you have to tell the linker a flag.
Go to your littlecms source folder and type the commands:
make clean
./configure LDFLAGS="-headerpad_max_install_names"
make
make check
Replace the compiled library with the PIL.
so long,
Phil
I am trying to convert a python script to an executable file.
I have tried cxFreeze and py2exe, but both told me that Python27 are not in the registry. I found several other questions that tell me to go to regedit and find the python folder, but it is not there. I tried going to HKEY_CURRENT_USER/Software and Python27 was not there.
Do I need to add it there to run the installer for cxFreeze or py2exe or is there another way?
Tools like PyInstaller package python scripts with the python run-time interpreter into standalone Windows applications. Installation of python (2.7.x) and all required python libraries is a prerequisite.
My suggestion is to install the latest Python 2.7 from this location: https://www.python.org/downloads/release/python-2710/. Make sure to choose the correct architecture, apparently 32-bit is the easiest to get working.
I fixed the issue. Apparently I accidentally installed 32-bit Python on a 64-bit machine. So I have to use the 32-bit installer because it installs the registry key in a different place. Thanks for the help anyways.
I'm trying to compile a Python 3 file into a Windows executable from inside Ubuntu using Nuitka with the instructions here. When trying to compile, I get the error
Error, no 'Python.h' development headers can be found, dependency not satisfied!
It works when I try to compile for Linux, though
I have the python3-dev package installed and have Python 3 installed in Wine. What can I do to install the Python development headers in Wine?
EDIT: It seems that the header files exist at /home/$USER/.wine/drive_c/Python33/include but Nuitka doesn't see them?
Has anyone successfully created a Windows executable file using py2exe, cx_Freeze or Pyinstaller under Wine from a Linux machine?
My goal is to be able to just push the code to a gitolite repository Ubuntu server then a git-hook will build the exe for windows and publish them for distribution. I've tried using cx_Freeze to no avail; pyinstaller seems to work but needs pywin32 which crashed during installation in wine.
If someone has successfully done so, how did you do it and did you have to install all the Python modules that were required by the application to be "compiled" for the wine-python installation? The specific application for which I want a windows exe is the Tryton Client.
Acсording to py2exe wiki, it produces invalid Win32 executables.