How To Run Python Using Batch File

As We Know That Batch File Is A Script File Which Contain Commands Which Is To Be Executed In Command Prompt (CMD)


Requirements To Execute Python From Batch File

  • Make Sure That Python Is Installed & Configured Properly
  • Text Editor Like NotePad++ Or Sublime Text
  • Batch File Code To Run Python Script

Batch File To Run Python

  • Open Text Editor & Enter Following Code
  • @echo off
    title Execute Python [NarendraDwivedi.Org]
    :main
    echo.
    set/p filename=File Name :
    echo. 
    %filename%
    goto main
  • Save This File As Run.bat ( Or AnyName .bat )
  • Copy This File & Paste It In The Folder Where Python Scripts Are Present. For Example "D:\Codes\Scripts\"
  • Open This File And Enter File Name Of Python Script Which You Want To Execute
  • It Will Execute The Python Script Successfully

Run Python From Batch File

If You Don't Want To Write The Above Code In Batch File , Then You Can Download The Batch File Script From Here & Can Use It To Run Python Script