I have an annoying problem. I have a windows batch file, that does some initialization (mainly setting python paths) and then calls a python script. When the batch program is run, another window is opened for the python program. The problem is, whenever there is an error in the python program, window of course closes and I can't see the error, as I'm immediately returned to the original cmd window from where I called the batch script.

How can I pipe or display python errors in the cmd window?


Well, after trying out diferent solutions, i found that the best way is to add the -i parameter to the line, calling the python script, which runs the python interpreter so the errors are shown there. Heres an example:


ECHO Doing some initialization here
%PATH% = C:\CustomModulePath;%PATH%

python -i myscript.py

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.