Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

How do you make an installer for your python program

Im new to python, but I was thinking about making a program with python to give to my friends. They don't know much about computers so if I asked them to install python by them selves they couldn't do it, but what if I could make an installer that downloads some version of python that only has what is needed for my file to run and make an exe file that would run the .py file in its own python interpreter . I also did a Google search and saw the freezing applications I could use to make the code into exe files to distribute (cx_freeze I use python 3.2), but not all of my friends have Windows computers and I rather Have my program so in each new version it auto updates by making a patch to .py file and not completely re-installing it .

** I am not looking for anything to make a stand alone executable . Just some kind of installer that bundles a minimalistic version of the python version your using . And an option to have an exe that is just a link to run the python file in the portable python interpreter, just for windows and a .sh file that would do the same for linux.

like image 785
Malcolm2608 Avatar asked Mar 31 '12 23:03

Malcolm2608


People also ask

How do I create an installer for Python?

Steps To Make Installer From .Step 1: Download inno setup software. Step 2: Choose Create new script file using the Script Wizard. Step 3: Fill Application Information. Step 4: Add files and folders and click on Next.

Where is the Python installer?

By default the Python installer for Windows places its executables in the user's AppData directory, so that it doesn't require administrative permissions. If you're the only user on the system, you might want to place Python in a higher-level directory (e.g. C:\Python3. 7 ) to make it easier to find.


2 Answers

Python is an interpreted, not a compiled language. So any standalone program you may want to distribute must bundle the entire interpreter inside it plus the libraries you used. This will result in an enormous file size for a single program. Also, this huge install cannot be used to run other python programs. An only marginally more complicated, but far better solution than this, is to just install the interpreter once and run any python program with it.

I understand that the point of your question was to make a standalone executable, so I know I'm not answering it. But not being able to create executable standalones is one of the caveats of interpreted languages. However, a fundamental point here is about the whole objective of an interpreted language, which is a single interpreter with all the generic functions required to run any python code (which now happily needn't be any longer than they need to be). So you see, it's not really a caveat, this was the whole intention of interpreted languages. You might finally find a way to create a standalone python executable that runs on your friends' computers, but that would defeat the entire framework and idea behind an interpreted language.

like image 138
Abhranil Das Avatar answered Oct 05 '22 05:10

Abhranil Das


Pyinstaller is a good option to convert them to an windows executable. You can install it in cmd.exe as admin and run pip install pyinstaller or pip install --pre pyinstaller.

you can then run it using pyinstaller. (sorry that i can't supply a automated script i wrote after a system restore. I'll write it again soon using pyqt5)

syntax

--onefile - puts the program and it's files into a exe.

--onedir - put your program into a directory (folder) (faster than --onefile as it does not need to extract files)

-c - create a console app.

-w - create an app without the console.

-i "[Path to .ico or exe with icon. e.g C:\Files\CODE\Icon.ico]" - create an app without the console.

you can read the rest here.

You can then get inno setup and create an offline installer.

If you need a web installer (it downloads a file and extracts it.) I am currently writing one and would be glad to create one for you.

like image 25
LethDev2019 Avatar answered Oct 05 '22 07:10

LethDev2019