Python Forum
Running Python in Command Prompt
Thread Rating:
  • 0 Vote(s) - 0 Average
  • 1
  • 2
  • 3
  • 4
  • 5
Running Python in Command Prompt
#1
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
Reply
#2
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.
Reply
#3
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.
Reply
#4
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.
DougBTX likes this post
Reply


Possibly Related Threads…
Thread Author Replies Views Last Post
  What is the difference between Command Prompt and Sublimes yaoyao22 1 634 Jul-09-2023, 02:56 PM
Last Post: snippsat
  Open windows cmd prompt and run cmds with python Extra 3 1,439 Jul-14-2022, 06:07 AM
Last Post: Gribouillis
  Facing Problem while opening a file through command prompt vlearner 4 1,901 Jan-30-2022, 08:10 AM
Last Post: snippsat
  Noob warning: trying to use pip to install pytest and pep8 in Command Prompt adifrank 4 5,306 Dec-20-2020, 04:23 AM
Last Post: adifrank
  Sound Approach for Running a Shell Command? matt_the_hall 8 3,340 Dec-14-2020, 02:52 PM
Last Post: matt_the_hall
  Error when running mktorrent subprocess command pythonnewbie138 4 3,836 Sep-16-2020, 01:55 AM
Last Post: pythonnewbie138
  starting python from windows command prompt MaartenRo 4 2,800 Sep-04-2020, 12:25 PM
Last Post: MaartenRo
  Running script from Anaconda prompt acollins555 0 2,579 Jun-15-2020, 03:40 AM
Last Post: acollins555
  Will not print in command prompt PandaCode 12 13,040 May-06-2020, 03:48 AM
Last Post: PandaCode
  Script works when executed from command prompt but not when executed in SDP Tippex 0 2,000 Apr-07-2020, 04:26 PM
Last Post: Tippex

Forum Jump:

User Panel Messages

Announcements
Announcement #1 8/1/2020
Announcement #2 8/2/2020
Announcement #3 8/6/2020