Python Forum
NameError: name 'python' is not defined
Thread Rating:
  • 0 Vote(s) - 0 Average
  • 1
  • 2
  • 3
  • 4
  • 5
NameError: name 'python' is not defined
#1
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 ?
Reply
#2
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
Craig "Ichabod" O'Brien - xenomind.com
I wish you happiness.
Recommended Tutorials: BBCode, functions, classes, text adventures
Reply


Forum Jump:

User Panel Messages

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