how to Run .py file

451 Views Asked by At

I have written a "random movie suggester" code that will basically read the files of the directory where the .py file is stored and randomly pick one of them and print it out.

My problem is -

How to make .py file simple to run for non-technical person? (e.g. I tried .bat but i had to hard code the path of the file).

Other solutions ask to install IDEs and run it.

1

There are 1 best solutions below

0
On

First you have to install python on your computer. Then you can type in your terminal:

python [the file name or the path to access it]

But I don't think this is what you are looking for...
You can create a .exe file with your python program using the pyinstaller module then running this in your terminal.

pip pyinstaller
pyinstaller --onefile [the name of the file]

The first line installs the module using pip.
The second line will create a .exe file that does exactly the same as your python code.