0

I wanted to ask help from this community for a solution for this: I made a python gui that I can run fine when using the terminal in pycharm. Now, I want to be able to run it through a .bat file (or a similar method) so that I don't have to go through opening pycharm everytime. This is because I will hand it over to someone who might not have pycharm installed in their pc, so just double clicking the .bat file will run the gui. I also want to restrict them from seeing my codes so running it by just clicking something would be ideal.

I have tried the ff methods so far but none of them worked for me: I wrote the ff in a notepad and saved them as a .bat file

First: start "" "location where my python is\python.exe" "location where my python file is\GUI.py"

second: @echo off "location where my python is\python.exe" "location where my python file is\GUI.py" pause

Is there a way to do this? Thanks a lot!!

메이유
  • 21
  • 1
  • This has been asked on Stackoverflow a few times. For example, see @Gerhard's answer in [Running Python script in my Windows bat file](https://stackoverflow.com/questions/44211529/running-python-script-in-my-windows-bat-file) – Qwerty May 06 '22 at 12:32

1 Answers1

0

This can be done in a text file. First you add the path to where your python exe is stored, then the path to where your python script is stored. Example:

"C:\Users\AppData\Local\Programs\Python\Python39\python.exe" 
"C:\Users\Desktop\Test\foo.py"

save this file as a .bat instead of .txt and change "save as type" from txt file to all files. when saved correctly you can make a shortcut to your desktop to launch it from there. Hopfully this helps!

liteversion
  • 49
  • 1
  • 8
  • I already tried something like this as mentioned but the problem is the gui doesn't show up if I run it from the .bat file vs when I run it from the terminal when it shows up properly – 메이유 May 11 '22 at 07:27