1

So I've made a script/code in python idle and want to run it on python.exe but whenever I do this the you can see the python window pop up briefly for a second before closing, and I want to run my code using python instead of idle, how can I do this?

1
  • What OS? What does 'do this' consist of. What does your program do? It is possible that you have already done what you want to do -- successfully run with python.exe. Why do you think you failed? Commented Jun 18, 2020 at 15:52

2 Answers 2

1

since I cant comment yet:

go to the command line and open the file location directory and type: python filename.py

Sign up to request clarification or add additional context in comments.

2 Comments

are you sure you do not have a syntax error in the code itself?
This is the default option for doing this. Are you opening the file in the correct directory ? E.g.: C:\Users\Docs\Folderl\>python nameoffile.py
0

This can be done using two methods. The first one is using cmd. Such as YOUR_WORKING_DIR>python filename.py Another method is to create .bat (batch) file that executes your particular python code. Let us assume you want to run my_python_file.py using a batch file. relevant script similar to this,

ECHO ON
python my_python_file.py
PAUSE

Save this file as .bat extension and just double click it! Incase the above method didn't work for you, Please refer to this answer.

7 Comments

I've tried both of these, the .bat file dosnt run and the filename.py comes up as syntax error
Have you set python in your path variable
That's the problem when I try set python as a path variable or try open it already in the python command line it treats it as either not defined, not a command of a syntax error
Open cmd and type python and press enter. If it says "Python is not recognized as an internal or external command," then follow these steps.follow this url
python: can't open file 'file name': [Errno 2] No such file or directory
|

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.