Skip to content Skip to sidebar Skip to footer

Use Python Without Installing

I have an installer which uses a Python script to install several components. I do not want to install Python on the users computer if they do not already have it and I also do not

Solution 1:

Portable Python is an easy tool to use on Windows. If you want to create .exe programs use PyInstaller to compile them. They can both work on top of each other, you can compile (make .exes) using Portable Python, Portable Python 3 is also available.

Solution 2:

If the installer is for OS X or Linux, Python shall be there usually. Otherwise

  • Lazy way: Detect if Python is existed. If not, ask user to install it as dependency. e.g. A link for python download page.

  • Rewrite your script. If the logic is not complicated, use some other build-in shell script is a good idea.

  • Static linking Python. Yes, static linking is evil. However, it's still an option. Found some project maybe helpful on github and google-code

Solution 3:

(In addition to Owens points). Use py2exe or one of the other exe builder utils for python on windows. On other platforms just use the python script.

Solution 4:

Try cx_Freeze

This program can freeze your python code into a .exe file and some other pyd files, it can be run without installing python.

NOTE: You will need to install python to freeze, but you don't need python to run the program.

You can download from here.

https://anthony-tuininga.github.io/cx_Freeze/index.html

TO FREEZE: make a file setup.py type

from cx_Freeze import setup, Executable

setup(name='NEW_EXE_FILE_NAME',
   executables = [Executable("xx.py")])

xx.py will be the python code you want to freeze.

command line: python setup.py build

Post a Comment for "Use Python Without Installing"