How to run a . py program by python IDLE on Windows?

Asked

Viewed 30,328 times

2

I’m learning to code in python and I’ve made a small program, but I can’t run it through the python terminal (IDLE or sheel) program name:salario_real.py error

inserir a descrição da imagem aqui

  • 1

    It seems to me that you are in the command mode of the Python interpreter, the Python Shell. To run a program in Python, you need to type python meuPrograma.py at the command prompt.

2 answers

1


To run a Python script, you need to be at the Windows command prompt, so just type the following:

python meuPrograma.py

Or if you want to run the script in IDLE interactively, you will have to use a function for this.

Running IDLE script with function execfile:

execfile('meuPrograma.py')

This way you can run script in IDLE.

Source.

0

With the screen of IDLE open you must perform the following steps:

  1. Click on the menu File;
  2. Click on the option Open;
  3. Navigate to the folder where your script file is (meu_file.py);
  4. Select the file;
  5. Click on the button Abrir.

At this time the file you have selected will be opened.

Now, for you to make the file that was opened run in IDLE, you must press the key F5.

At this time your script .py will run on the screen of IDLE.

Browser other questions tagged

You are not signed in. Login or sign up in order to post.