Python Forum

Full Version: NameError: name 'python' is not defined
You're currently viewing a stripped down version of our content. View the full version with proper formatting.
Dear all,

I am new to Python - I completed the Introduction to Python on DataCamp and now i want to experiment and run commands from my "own" shell.

I have installed 3.7.2 64-bit on W10 and started the IDLE program that comes with Python. In the interpreter it says:

Python 3.7.2 (tags/v3.7.2:9a3ffc0492, Dec 23 2018, 23:09:28) [MSC v.1916 64 bit (AMD64)] on win32
Type "help", "copyright", "credits" or "license()" for more information.
>>>

That is fine. If I want to check the version it goes like this:

>>> python -V
Traceback (most recent call last):
File "<pyshell#0>", line 1, in <module>
python -V
NameError: name 'python' is not defined
>>>

Can anyone tell me what goes wrong ?
python -V works from the system command line, not the command line in the Python interactive shell. If you want to get the version from within Python, try:

import sys
sys.version