Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

creating stand-alone executable for windows from python code

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

like image 679
Ashish kulkarni Avatar asked May 29 '15 06:05

Ashish kulkarni


People also ask

Can Python code be converted to EXE?

To convert the Python code into an executable file, we will be using Pyinstaller package. Use the standard 'pip install' command to install this package.

Can Python run standalone?

With BuildApplet you can build a standalone Python application that works like any other Mac application: you can double-click it, run it while the Python interpreter is running other scripts, drop files on it, etc.

Can Python script be run as an executable?

py extension with a file type (Python. File) and gives that file type an open command that runs the interpreter ( D:\Program Files\Python\python.exe "%1" %* ). This is enough to make scripts executable from the command prompt as 'foo.py'.


2 Answers

I'd recommend using pyinstaller

Example:

$ pip install pyinstaller
$ pyinstaller -F myscript.py

You should now have a build/myscript/myscript.exe executable.

like image 136
James Mills Avatar answered Sep 29 '22 03:09

James Mills


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.

like image 38
Doogle Avatar answered Sep 29 '22 03:09

Doogle