[ Home ] [ Tech Tips ] [ Raspberry Pi ] [ Powershell ] [ Ubuntu ] [ Django ] [ About ]
Python | Start Python Script via Run.bat

Python | Start Python Script via Run.bat 

Easy one today where we are making a .bat file to run a Python script. 

This assumes your file is called main.py and that your virtual python environment is in .\venv\Scripts\python.exe so adjust accordingly or remove the venv part if you aren't using a virtual environment which I highly recommend you do.

 

SET ThisScriptsDirectory=%~dp0
SET PyScriptPath="%ThisScriptsDirectory%main.py"
"%ThisScriptsDirectory%venv\Scripts\python.exe" %PyScriptPath%
pause

 

Most up to date version of this file is at 

https://github.com/LukeKeam/python-start-script-bat

 


Luke Keam
Thank you for reading. Any questions, comments or suggestions email me [email protected]
Luke Keam
techgeek.biz

FOLLOW US

Name
Email:

AD

quick-time-management logo.biz

Quick-Time-Management.com

We strive to make you healthy and productive for the long haul. Easily look back and see how you effective you have been.