2

For learning purposes, I wrote a test.py which simply will print out "Hello World". Now the problem is that I want to have like an installer for Windows so the program installs and executes after being installed.

test.py

hello()

def hello():
    print('HELLO WORLD')

So do I have to change the code in the program a little bit or something else?

Marcus Müller
  • 34,677
  • 4
  • 53
  • 94
  • 2
    brevity is a virtue on these sites. You don't have to introduce yourself, nor have to thank us in advance – to-the-point questions speak louder than polite, but information-free phrases! – Marcus Müller Nov 07 '17 at 21:54
  • 2
    If you're new to programming in general, you may just want to get familiar with python and the basics before anything else. Trying to do too much at the start usually just discourages people. – SuperStew Nov 07 '17 at 21:54
  • 1
    Possible duplicate of [How can I make an EXE file from a Python program?](https://stackoverflow.com/questions/49146/how-can-i-make-an-exe-file-from-a-python-program) – bhansa Nov 07 '17 at 21:55

1 Answers1

0

You do not need an installer. You can create a standalone file that executes on open with any compiler.

I mostly use pyinstaller. If you have pip already installed you can execute following command in it pip install pyinstaller

Make sure pip is in your Path. If not, google for add pip to path

Then, navigate into the folder with the test.py and open a new cmd.

Now type pyinstaller test.py --onefile and press enter.

It should now create some new folders inclduing one called dist. In there you can find the standalone exe.

Michi Gruber
  • 254
  • 3
  • 18