How to open python programs without having python installed on another PC - python

I need to be able to send someone a python program but they dont have python, is there a way to compile the python program and open it as a normal computer program.
Any help would be appreciated

Yes, you can use cxfreeze. Documents are here.
Gist of them is that you need to create a distutils setup file to specify which modules are required and any other resources that should be included. You can then run python setup.py build to create your build application.
As mentioned in the docs, you can then use something like inno setup to make an .exe file from the output of cxfreeze.
It's been a while since I've used it but I can look back over how I set it up if you need any more help getting it running.

Related

Can I compile a python script to an executable file, so that cannot be reversed back to the source code?

I want to create a python .exe file in order to sell it to a client, however I'm worried that python can easily be reversed and the source code can be found, rendering my work less valuable for the future. Is there any way I can compile python code and make it irreversible?
Any other suggestions to go about solving this issue are welcomed.
you can also install auto_py_to_exe with pip, call it in your terminal to open it, just select your .py file and itll convert it to an .exe for you

Pyinstaller / auto-py-to-exe additional files

I have a python script that uses the face_recognition library(as well as other libraries), and want to make an .exe file out of it. I use pyinstaller, but I get the following error when trying to run the .exe file:
I guess it needs a hook or something, but I am not really familiar with how to write one or what the contents of it should be. I had a similar problem in the past with another python script I was trying to make into an .exe file, and luckily someone knew how to help me out. It would be great if someone could guide me through this.
Since the exe is complaining about a missing module "pkg_resources.py2_warn2 add --hidden-import=pkg_resources.py2_warn to your build command
To complete the job you should read https://github.com/ageitgey/face_recognition/issues/357
If you're trying to make an .exe file with libarys, I would recommend using https://pypi.org/project/auto-py-to-exe/ auto-py-to-exe, i've used it many times and it works great.
I had the same error.
I fixed this by adding the required libraries to the python environment that auto-py-to-exe or pyinstaller uses

Making serveral python files to an executable

I have two Python scripts, one as User Interface and one as background process. I need both of them because there is a sub-process and the UI. However I want it together get a executable.
I tried it with py2exe, which can only compile one of them.
Next I used pyinstaller but that has the same problem
pyinstaller user_interface.py
# and with py2exe
from distutils.core import setup
import py2exe
setup(console=['hello.py'])
What you need to do is some kind of packaging. First try to create a package using setup.py which you can use directly through python console by importing that package. and then you can create an executable out of it. Please refer the example in mentioned link.
Please refer this link: real python tutorial
You can write a small launcher script that spawns both processes, and then package that file.
I never used py2exe or pyinstaller, so I don't know how python dependencies are managed. If having code split in several files is a problem, then you can just concatenate you two existing scripts and the launcher in one single file.

Single EXE to Install Python Standalone Executable for Easy Distribution

I used Pyinstaller to create a standalone exe file for a PyQt project. I did not use the single file option because the exe that is created with the single file option takes too long to open. Therefore, Pyinstaller created a dist folder that contains a bunch of files including my program.exe file. I would now like to create a setup.exe file that will place the contents of my dist folder in the program directory and create a shortcut in the start menu and on the desktop. I want it to be super simple for the user. Maybe like the setup.exe files that you get when you download a program from CNET. I found Inno-setup, which looks promising. However, I do not know if there any special considerations because the program is a standalone program create from a python/PyQt program. Thanks! Anyone have experience with this task? Is there a program everyone is using for this task that I do not know about?
Inno-Setup or NSIS are probably the easiest to use. You just tell them what files to include and where to put them and then they will create a nice installer for you. I wrote a short tutorial on my experiences using InnoSetup that you might find helpful:
http://www.blog.pythonlibrary.org/2008/08/27/packaging-wxpymail-for-distribution/
Note that this tutorial was based around a wxPython app I wrote, but the concepts are the same.

Should I include the .pyc byte code when saving a project to a read-only storage?

Yes, I read some of those .pyc questions, but still nothing.
I need to save a project to a CD and preferably I'd like to be able to run it right from there. Should I put the .pyc files in there or not?
No,
byte-code is not version compatible
Yes
the project is supposed to run with the same python version
.py files won't be changed any more in that release
it might be load faster
if smth doesn't suit, python will (need to) create new .pycs somewhere anyway
The latter one: Python will handle that and use a temp directory, won't it?
Answer : No Need to Include
You want to Compile & Run Means :-
Your question says, you are going to compile your python source code in another machine. When you compile your code, the ".pyc" file will be created. So, it is not necessary to include the ".pyc" file with your cd. If you put means, no problem, when you compile your source code in another machine, it will replace the ".pyc" file with the newly created ".pyc" file.
You want to Only Run Means:-
But, if you want to run without compile means, you should convert your program into executable. Executable file may be for windows or linux.
For Linux, to create executable file : Use "CDE" package.
Link: http://www.pgbovine.net/cde.html
For Windows, to create executable file : Use "Py2Exe" package
Link : http://www.py2exe.org/index.cgi/WorkingWithVariousPackagesAndModules
I hope this is the answer you want.
PYC is python bytecode making the original code run faster. You can omit it, since your code will still be able to run.
However if you need to run your code on different machines, probably without any python distribution. Take a look at
http://www.py2exe.org/ which is for windows only
http://www.pyinstaller.org/ which is for most systems
I personally worked with py2exe, it is simple to use. Although it makes fairly huge package, since it add all python packages required to run the original python script.
Hope this is helpful for You.

Categories

Resources