How to make python program standalone executable under linux
I have done some research but I am not looking for a way to make a script and run the .py file like answered in this question. What do I use on linux to make a python program executable
I am looking to "complie" the .py to a standalone program so users in a linux environment like ubuntu can run it out of the box without installing python and the libraries I used because no root access.
I found py2exe for windows. I would think there is a way to achieve this in linux?
Doesn't pyinstaller compile under the OS you are using?
if you want a windows exe - use pyinstaller in windows environment...
For Linux, use pyinstaller in Linux.
You can use Jython to compile it to JVM. Using the Jython compiler
jythonc [options] [module]*
This would, however, require Java to be installed...
There are also a couple of other resources to compile Python. From Compiling Python Code, some cross-platform tools are
Gordon McMillan’s installer (cross-platform)
Anthony Tuininga’s cx_Freeze (cross-platform)
but I do not know anything about those.
Related
I used Pyinstaller to make a standalone portable application for windows from python code, and it works normally.
I understand that to create an executable for a certain OS it must be done on that specific OS.
Is there a way to create executables for other platforms directly from windows without running a virtual machine.
Thank you.
Since pyinstaller is not a cross-compiler (which means with pyinstaller you cannot create an executable for any other system than the one you are on), you will have to look for other tools.
On the official github FAQ, they recommend using Wine for this specific purpose.
Link to FAQ.
Since you don't want to look for other systems to compile your code on, this seems to be the only option.
if you have docker-expertise, you could try to get the docker-containers in the following link to do the job for you (creating the executable for windows/linux by setting up a docker-container for each target-system) and starting up the Docker-Containers for Building the Executables from within your Windows-OS. I have not tryed it out though, but the Readme of the project sounds promising.
https://github.com/cdrx/docker-pyinstaller
If the project does what it says, you would only need to execute the following two commands in your project-folder to create the executables for Windows and Linux, when you have gotten everything setted up:
docker run -v "$(pwd):/src/" cdrx/pyinstaller-windows
docker run -v "$(pwd):/src/" cdrx/pyinstaller-linux
In order to make executable files for Mac and Linux, you need to build it on the same systems
For example, in order to make your Linux work, you need to collect the rpm package
No, pyinstaller isn't a cross-compiler, so just use VM.
I wrote a Python script that scrapes PDFs that are in the same directory as the file itself.
I used pyinstaller on my Mac to convert this to a onefile .exe on my MacBook Pro and it works great. However, when I try to send this file to someone else via email, it doesn't open because "it's a Windows file", despite the fact that it was compiled/bundled on a Mac. The modules I use are regex, PyPDF2, among other non-standard libraries. How do I make these executables run on different computers?
I've tried using auto-py-to-exe, but to no avail.
The executables work as built on my Mac, but when I email it to someone whose Mac does not have Python/IDLE installed, I run into a wall. If it makes a difference, I've made a version for Windows, and that works great, too.
AFAIK, you need to compile Python programs separately for each environment. If you're on Linux, give crossenv a try.
If you aren't on Linux, to build packages that work on a Mac without IDLE installed, try py2app.
You can also suggest that whoever you're sending this file to install wine, which will let them run the .exe (though installing python might be a tad easier for them.)
I've created a kivy app that works perfectly as I desire. It's got a few files in a particular folder that it uses. For the life of me, I don't understand how to create an exe on mac. I know I can use pyinstaller but how do I create an exe from mac.
Please help!
For pyinstaller, they have stated that packaging Windows binaries while running under OS X is NOT supported, and recommended to use Wine for this.
Can I package Windows binaries while running under Linux?
No, this is not supported. Please use Wine for this, PyInstaller runs
fine in Wine. You may also want to have a look at this thread in the
mailinglist. In version 1.4 we had build in some support for this, but
it showed to work only half. It would require some Windows system on
another partition and would only work for pure Python programs. As
soon as you want a decent GUI (gtk, qt, wx), you would need to install
Windows libraries anyhow. So it's much easier to just use Wine.
Can I package Windows binaries while running under OS X?
No, this is not supported. Please try Wine for this.
Can I package OS X binaries while running under Linux?
This is currently not possible at all. Sorry! If you want to help out,
you are very welcome.
This is easy with Pyinstaller. I've used it recently.
Install pyinstaller
pip install pyinstaller
Hit following command on terminal where file.py is path to your main file
pyinstaller -w -F file.py
Your exe will be created inside a folder dist
NOTE : verified on windowns, not on mac
I have written a python GUI application.I want to run the code on my friend's computer who doesn't have python interpreter in his computer and that he can't download since he can't connect to the internet.How do I make that happen?
Use py2exe (for Windows), py2app (for Mac), or cx_freeze (for Linux) to bundle the Python interpreter, your program, and the standard library into an executable you can use on a machine with no Python at all.
PS: If your friend's computer isn't on the Internet, however you'd get him your program, you can also get him the kits for Python, etc.
py2exe is a library that allows you to compile Python executables for Windows. There's also cx_Freeze, which is cross-platform.
is there any way to converts Python scripts into executable Windows programs on linux
i know py2exe and pyinstall will work well on windows
but i only has linux Environment
Why would you want to convert it to a windows executable on a linux platform? Anyway, I'd say you have two options:
Use py2exe with wine (a Windows emulator). I've done this, and it works
If that is not possible, you could try pyinstaller. I haven't tried it, but it seems to be sort of the same, but multi-platform
cx_Freeze will do you the job.
http://cx-freeze.sourceforge.net/