My print function does not work at windows command prompt

Asked

Viewed 223 times

0

I’m starting to study programming. I downloaded version 3.8.3 of Python and to write the programs I downloaded the Sublime text that allows running the programs on the platform itself.

When I started working normally, I was able to run the programs in both Sublime text and Windows prompt (I have Windows 10), but I did not study for a while and when I went back now the print function does not work through the prompt, only through Sublime text. When I try to run through the prompt the window opens and closes very quickly, which didn’t happen before.

The strange thing is that my girlfriend sent me a program by email and the program she made runs smoothly by Windows prompt, but the ones I do on my computer do not.

I tried to see if it was a typo, so I wrote a very simple program:

print ("Hello World")

And yet it didn’t work.

I already uninstalled and installed Python and nothing. I tried writing the program using another text tool and it didn’t work either. I saw that I could look at Python’s help() to see if everything was right and it is.

Is it some problem with Windows?

  • During the installation of the Python (official website) the installer asks if you want criar the Python environment variable. If you are disabling this option during installation, Python will not be reconhecido in the prompt de comandos. I suggest reinstalling Python habilitando the definition of variável de ambiente.

  • Another thing, it’s good to know that atualmente exists in operation two versions of Python incompatible with each other. The version 2 and the version 3. This means that, programs created in Python 3 will not be executed by version interpreters 2 or vise-versa.

2 answers

1

How exactly are you running the program? (I can’t leave a comment because I don’t have enough score).

First you must make sure that the Python installation is ok on your machine running python --version on your terminal. If you show the right version, it is pq is ok. If you do not recognize the command you must redo the installation.

Once the installation is correct, run the command python, this will place you inside the Python interpreter. There you can execute several commands individually, including the print("Hello, world!").

To run a program you have in a file, run the command in the terminal python nomeDoArQuivo. Make sure that the file has extension . py, and that you are running the command in the same directory as the file. I hope I helped.

  • 1

    Just to complement your answer, it is good to realize that during the installation of the Python (official website) the installer asks if you want criar the Python environment variable. If you are disabling this option during installation, Python will not be reconhecido in the prompt de comandos. I suggest reinstalling Python habilitando the definition of variável de ambiente.

0

Hello, good night!

It worked running the command python Filename.

Thank you very much for your reply!

Browser other questions tagged

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