Python Forum
Running Python in Command Prompt - Printable Version

+- Python Forum (https://python-forum.io)
+-- Forum: Python Coding (https://python-forum.io/forum-7.html)
+--- Forum: General Coding Help (https://python-forum.io/forum-8.html)
+--- Thread: Running Python in Command Prompt (/thread-30954.html)



Running Python in Command Prompt - Anwar - Nov-15-2020

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: Running Python in Command Prompt - ssrobins - Nov-15-2020

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.


RE: Running Python in Command Prompt - Anwar - Nov-15-2020

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.


RE: Running Python in Command Prompt - snippsat - Nov-15-2020

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.