I wrote a Python program with GUI built using tkinter. I want to share my project as an open-source software in Git. My goal was to enable the end-user to download/clone my repository and run an executable present in it.
So I made my Python file to an executable using pyinstaller. I then pushed all the files created by the pyinstaller (ex: dist, build files) to my repository. Is this the correct way to distribute a software?
Though I wrote my software only using Python, the files created by pyinstaller dominated the result:
Furthermore, when I tried cloning my repository the executable present in it throws an error, though the executable I created originally works without any problem.
I used the flag --onefile to create the executable using pyinstaller. Someone please help me out.
It might be getting blocked, I would recommend creating a release in Github and archive the executable so others can download it from there or you can just archive the executable. Not sure if Github blocks plain executables or not but is safer to just archive it into a .zip or a .rar, or .tar file.
Related
I don't know if my question is ambiguous or not but, I noticed that in Scripts folder inside the python installation folder there are executable files. Each file about a 100kb in size.
FYI: when I open it (or them) using 7Zip I often find a init.py file inside.
Thanks
I have tried researching but can't seem to find the answer.
The setuptools package builder is able to
Automatically generate wrapper scripts or Windows (console and GUI) .exe files for any number of “main” functions in your project. (Note: this is not a py2exe replacement; the .exe files rely on the local Python installation.)
(ref. from setuptools documentation)
Unfortunately the way it is actually done is considered an implementation detail and is not documented.
I am trying to make an executable file for some python script. This application is a console level application which uses parameters for execution.
I have compiled and did build the executable (exe) file using pyinstaller. The exe file is build successfully and running fine.
However now I want to include the version, author name and description for this executable file, I searched for multiple options but don't seem to find a solution.
Any help or references would be really appreciated.
For a macos application, you can put the version in the app section of the spec file, and then build with pyinstaller name.spec.
See the documentation here.
I don't know about other platforms, and I'd also like to know how to set the author and other metadata (eg email address).
I have created python desktop software. Now I want to market that as a product. But my problem is, anyone can decompile my exe file and they will get the actual code.
So is there any way to encrypt my code and convert it to exe before deployment. I have tried different ways.
But nothing is working. Is there any way to do that?.Thanks in advance
This link has most of the info you need.
But since links are discouraged here:
There is py2exe, which compiles your code into an .exe file, but afaik it's not difficult to reverse-engineer the code from the exe file.
You can of course make your code more difficult to understand. Rename your classes, functions to be non-sensical (e.g. rename print(s) to delete(s) or to a()) people will have a difficult time then.
You can also avoid all of that by using SaaS (Software as a Service), where you can host your code online on a server and get paid by people using it.
Or consider open-sourcing it :)
You can install pyinstaller per pip install pyinstaller (make sure to also add it to your environment variables) and then open shell in the folder where your file is (shift+right-click somewhere where no file is and "open PowerShell here") and the do "pyinstaller --onefile YOUR_FILE".
If there will be created a dist folder, take out the exe file and delete the build folder and the .spec I think it is.
And there you go with your standalone exe File.
I've been searching through SO for a while now trying to come up with an answer to this but due to my inexperience with programming I don't understand much of the documentation, nor am I confident enough to experiment too much.
Would anyone be able to describe in slightly simpler terms how I would use programs like Py2exe, PyInstaller, cx_freeze etc.? I just want a way for others (mainly friends) to be able to run my (simple, text only) program without having to download python themselves. If there is an easier way to do this I'd appreciate knowing that too.
Running Vista 32bit, python 2.7
There are two distinct ways of freezing python scripts to create executables:
Packing the interpreter and *.pyc files into one exe file-container. Such an approach is used by tools like PyInstaller, Py2exe, cx_freeze.
Creating native code from Python source, usually using a middle step of converting Python-source to C or C++ code. This is done by such tools as Shed-skin and Nuitka. The problem of this aproach is that such tools do not always support all the functionality of Python (e.g. they can have some typing limitations and so on)
The point where you have to start is reading the documentation. Such tools are not just push-and-run style tools, they usually have some configuration that must be implemented (that's the problem of possibly all build systems, and as the project grows, the configuration and number of hooks also grows).
You can start with Py2exe tutorial and 'hello-world' to get acquainted with that how compilation is done. As far as I know it's a simplest way to get your goal.
And the last thing, you can't create cross-platform native executables as their file formats are strongly operating system and hardware dependent.
Download py2exe
Download this msvcp90.dll
Copy your FileCode.py AND msvcp90.dll to C:\Python27\
In C:\Python27\ create new text file, then enter this code inside it:
from distutils.core import setup
import py2exe
setup(console=['Avril.py'])
Replace Avril.py with YourFileName.py
Save the file as setup.txt
Open CMD and type this:
cd C:\Python27\
python setup.txt py2exe
Now go to C:\Python27\dist\ and there's your .exe program.
Source: Manvir Singh
Python scripts can be made directly executable, like shell scripts, by putting the python environment path in the top of the script file.
#!/usr/bin/env python3.5
The Python installer automatically associates .py files with python.exe so that a double-click on a Python file will run it as a script. The extension can also be .pyw, in that case, the console window that normally appears is suppressed.
Detailed description also for linux is here.
Install pyinstaller, a program that converts .py to .exe for python 2.7 to where python is located:
cd C:\python27\scripts
pip install pyinstaller
then move whatever python file you want to compile to C:\python27\scripts, compile from there by using:
pyinstaller --onefile yourfile.py
the --onefile is optional but it packages the whole thing(in this example yourfile.py) into one .exe. Once everything is done there will be 2 new folders along with a .spec file. From C:\python27\scripts open the folder dist. Your .exe will be located there in one file which you can double tap to execute and distribute to anyone who doesn't have python. Hope it helps.
I have a python project, which uses qt(UI) for user input and then creates the pdf using latex.
I want to make full package of my whole projects in some form of exe.
I came to know about pyinstaller, pyexe and cx_frezer.
So which one should I pick up first.
My exe should run in windows 98, xp, vista and linux.
So how does MiKTeX ( windows) and qt get bundle to my exe.
Does I have to make different exe depending upon the operation system.
Any link for reading will be nice.
This might be a viable alternative to freeze and py2exe. Python allows compilation into bytecode. You will have to do this on all of your target platforms for specific python versions. Run in root of your project folder
python -m compileall
See http://docs.python.org/library/compileall.html for details.
After that, delete all *.py files leaving only *.pyc. Note that such compilations must work up to a specific three digits' version of python's runtime, so this is not very convenient.