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).
Related
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 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.
I am trying to run my python(3) web service using IIS 8 following the instruction provided here
Everything is fine to the point where I try to add "FastCgi Module" in "Add Module Mapping" section. The problem is when I click on OK on "Add Module Mapping" window, the error pops up:
The specified executable for the handler must be .dll or .exe file. If the path to the script processor (only in the case of a .exe file) has spaces, use " marks to specify the executable.
I suppose there has to be a FastCgi.dll?
Is there a better way to achieve that?
P.S: I have read an ample of instructions regarding running python 2.6 web services on IIS using ISAPI_WSGI Handler and there are warnings regarding using it on later python versions, I wonder if that instructions hold up using python 3.3.6.
When you add Executable setting, it must be an executable, this means that is has to be either .exe or .dll. If you look at the picture in the instructions, you will see an executable there (python.exe).
If you don't provide path to an executable, error that specified executable must be .dll or .exe will pop up. Make sure you are referring to an executable there and it should be fine then.
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 need some help with converting a python windows service using py2exe.
Let me explain the problem. I have a python service, which works, no problems here. I used py2exe to turn it into an executable file. I tested it by replacing the python version of the service with this one and it works with no problems too.
But when I move the exe version of the service to another computer, it will register with the service manager but won't start with the error: "The system cannot find the file specified". The missing file is one of the modules I've written.
I played with this a bit and went back to the machine where I used py2exe and where the exe version of the service works. I removed everything python related, everything py2exe created but the "dist" folder, everything I could think of that was related with the python version of the service. The exe version still worked (altho I removed, amongst others, the very files that were supposedly missing on the other machine).
Tried a bunch of different things but cant get the exe version to work. If any of you guys have any ideas, I'd really appreciate it.
P.S: I do have the c++ runtime installed on the target machine. You can't register the service without it and as I said, I can register it, it just won't run.
Even if you converted the .py script to an exe, the service still uses the python interpreter to run the service code itself. if you open "Services" and look at the service properties you should see something like -
Path to executable:
"C:\Python27\lib\site-packages\win32\PythonService.exe"
i'm guessing the other computer doesnt have python installed on it.
if you want to be able to run that service on a machine without installing python you need to do something like This
,or you can also do it using cx_freeze
http://www.py2exe.org/index.cgi/py2exeAndWindowsServices
There are some notes in there about modules conflicting with windows system dlls. He had a problem because he had a module called version and import version caused the app to error out.
You can try importing win32traceutil as the first thing in your service. This should allow you to run the win32traceutil console app to display any stdout/stderr output from the service.