Python Forum

Full Version: Creating a bat file to call Python from command line
You're currently viewing a stripped down version of our content. View the full version with proper formatting.
I have created a .bat file containing
@echo off
set PATH=C:\Users\Dimitris\AppData\Local\Programs\Python\Python36-32;%SystemRoot%\System32
C:\Users\Dimitris\Documents
cd \Programmes
cmd.exe
According to the book I am working this should call the command line from where I could program in Python language (sure I know about IDLE and Python shell!). I just want to figure out what I am doing wrong. Thank you very much in advance for your help.
Yes, that creates a command line in which you can call the Python interpreter. But it doesn't extend the PATH to include Python, it replaces your whole path so you can end up missing things. Do all these directories exist?
(Feb-18-2017, 12:18 AM)dimitrisana Wrote: [ -> ]I have created a .bat file containing
@echo off
set PATH=C:\Users\Dimitris\AppData\Local\Programs\Python\Python36-32;%SystemRoot%\System32
C:\Users\Dimitris\Documents
cd \Programmes
cmd.exe
According to the book I am working this should call the command line from where I could program in Python language (sure I know about IDLE and Python shell!). I just want to figure out what I am doing wrong. Thank you very much in advance for your help.

Not sure which book you are using, but let's presume you have Python installed correctly (including it's entry's in your environmental variables.  If that is true, then your .bat file need only be:
cmd /C c:\python36\python.exe
Note that the location of your 'python.exe' may be located in a different directory, if so, just replace the correct directory instead of "c:\python36".

Running the .bat will open the python interpreter and you can go ahead and start typing.

Output:
C:\Python>cmd /C c:\python36\python.exe Python 3.6.0 (v3.6.0:41df79263a11, Dec 23 2016, 08:06:12) [MSC v.1900 64 bit (AMD64)] on win32 Type "help", "copyright", "credits" or "license" for more information. >>>