cx_freeze makes python apps only executable. If python or neccessary modules is not installed, app doesn't open. How can i make Python 2.7 apps standalone with cx_freeze or any other app? (For Linux)
pyinstaller works under linux and also windows / OS X, look at http://pythonhosted.org/PyInstaller/
first simply do: pip install pyinstaller
to package your app: pyinstaller --onefile yourfile.py
Simple enough, isn't it?
Related
I'm trying to convert my python file to a .exe file.
The issue is, I'm using linux, and I can't use pyinstaller or cx_freeze to make .exe files from
.py.
Is there any way to do it?
I'm using Python 3.7.3 on Debian Linux.
TLDR: You can't.
You should be able to use PyInstaller to create executable files as it is compatible with Linux systems:
https://pyinstaller.readthedocs.io/en/stable/requirements.html#gnu-linux
pip install pyinstaller
cd /path/to/your/program
pyinstaller --onefile yourscript.py
However, at least for pyinstaller, there is no way to bundle an executable file for Windows on a Linux system that I know of:
The output of PyInstaller is specific to the active operating system and the active
version of Python. This means that to prepare a distribution for:
a different OS
a different version of Python
a 32-bit or 64-bit OS
you run PyInstaller on that OS, under that version of Python. The Python interpreter
that executes PyInstaller is part of the bundle, and it is specific to the OS and the
word size.
Source: https://pyinstaller.readthedocs.io/en/stable/operating-mode.html
How can I take all scripts and files in my Python project directory and create a single executable. I have tried using this: How do I create an executable file out of a PyCharm project using PyInstaller? but it does not work. I have developed the project in PyCharm and I am using Python 3.4.
You can use cx_Freeze it's the same way that py2exe and py2app. It supports python 2.7 or highter or you can use Pyinstaller that binds in an executable all the stuff.
You can download it using the following command:
pip install pyinstaller
Or you can download it from the website
I have a python code which uses the pygkt, gtk, ctypes, os and some other modules. I used pyinstaller to create a stand-alone executive of the code. It worked fine on ubuntu. Now I wanted to create another stand-alone executive for windows platform.
I used the tool https://github.com/paulfurley/python-windows-packager for it and followed the steps. But I got the error: module gtk not found.
How to fix the issue ?
Are there any other tools to convert python code to stand-alone executable for windows os ? If yes, please provide the details ?
Thank you
I'd recommend using pyinstaller
Example:
$ pip install pyinstaller
$ pyinstaller -F myscript.py
You should now have a build/myscript/myscript.exe executable.
If in Windows, Best way to do it is via Cygwin.
Ensure you have Python 3.5+ version not 3.6
pip install pyinstaller
Go to the directory where the .py file is which needs to be packaged.
Then run
$ pyinstaller --onefile test.py
Simple to have a single file executable.
I am running the command pyinstaller --onefile --windowed /myapp.py. According to the docs, this should output executables for windows as well as .app for MacOS. However, I am only getting one output and not the .app.
They don't make this obvious from the website, but from the docs:
If you need to distribute your application for more than one OS, for
example both Windows and Mac OS X, you must install PyInstaller on
each platform and bundle your app separately on each.
So you'll need to package it on a Mac, sorry.
I have a Python script I developed within a virtualenv on Windows (Python 2.7).
I would now like to compile it into a single EXE using Py2exe.
I've read and read the docs and stackoverflow, and yet I can't find a simple answer: How do I do this? I tried just installing py2exe (via the downloadable installer), but of course that doesn't work because it uses the system-level python, which doesn't have the dependencies for my script installed. It needs to use the virtualenv - but there doesn't seem to be such an option.
I did manage to get bbfreeze to work, but it outputs a dist folder crammed with files, and I just want a simple EXE file (one file) for my simple script, and I understand Py2Exe can do this.
tl;dr: How do I run Py2Exe within the context of a virtualenv so it correctly imports dependencies?
You can do that this way:
Activate your virtualenv and then ...
easy_install py2exe-0.6.9.win32-py2.7.exe
Installing py2exe into your virtual env should be straightforward. You'll need Visual Studio 2008, the express version should work. Launch a 2008 Command Prompt and Activate your virtual env. Change into the directory that contains the py2exe source and run python setup.py install. You can verify that py2exe is in the correct environment by attempting to import it from an interactive shell. I tested myself earlier today (had to install virtualenv). It works exactly as expected.