Python Forum

Full Version: Running Python in Command Prompt
You're currently viewing a stripped down version of our content. View the full version with proper formatting.
Hello everyone

I am a new member here and I wanted to start learning Python. I installed Python 3.9 today. It is working. But I wanted to run Python from the Command Prompt. It does not recognize Python from Command Prompt. Anyone can help me out?

Thanks
Re-run the Python GUI installer, select Modify, click Next, select 'Add Python to environment variables', and click Install. Once the installer is done, re-open your Command Prompt. There was a similar option on the first step of the installer if Python is already not installed.
C:\Users\mdani>python
Python 3.9.0 (tags/v3.9.0:9cf6752, Oct 5 2020, 15:34:40) [MSC v.1927 64 bit (AMD64)] on win32
Type "help", "copyright", "credits" or "license" for more information.
>>> python --version
Traceback (most recent call last):
File "<stdin>", line 1, in <module>
NameError: name 'python' is not defined

First it shows that python with version number in the command prompt. But if I type "python --version"
it gives me traceback NameError.

Please help me to install python correctly.
It's correct,but python --version is from command line,same as python command.
Test also pip.
λ pip -V
pip 20.2.3 from c:\python39\lib\site-packages\pip (python 3.9)
If want to show version from interactive shell >>>
>>> import sys
>>>
>>> sys.version
'3.8.3 (tags/v3.8.3:6f8c832, May 13 2020, 22:37:02) [MSC v.1924 64 bit (AMD64)]
Some tips here.