Python Forum
NameError: name 'python' is not defined
Thread Rating:
  • 1 Vote(s) - 1 Average
  • 1
  • 2
  • 3
  • 4
  • 5
NameError: name 'python' is not defined
#1

I have installed Python 3.6 and started Python. Then gave python -V command. I am getting the following error:
İmage


Python 3.6.3 (v3.6.3:2c5fed8, Oct 3 2017, 18:11:49) [MSC v.1900 64 bit (AMD64)] on win32
Type "help", "copyright", "credits" or "license" for more information.
>>> python -V
Traceback (most recent call last):
File "<stdin>", line 1, in <module>
NameError: name 'python' is not defined
>>>
>>>
Any suggestions for fixing this NameError please?
Reply
#2
type it in the operating system prompt, not python interpreter
Reply
#3
Thanks, very helpful information. Gave python -V command in DOS command window and it worked.
Reply
#4
But why does it work in cmd DOS and not in python interpreter?!?
+
I am always so confused about System Variables, PATH - does anybody have a good reference where I can commit it to memory ONCE AND FOR ALL!!

Thank you Much!
Reply
#5
in python you can use

import sys

cdPyVer = 0x600
cdSysVer = sys.version[:5]
print("%s%s" %("my python version is: ", cdSysVer))
python
Output:
my python version is: 2.7.1
python3
Output:
my python version is: 3.5.2
Reply


Possibly Related Threads…
Thread Author Replies Views Last Post
  “NameError” “is not defined” script that I know works on other computers iamwithstupid 0 57 Nov-24-2020, 04:23 PM
Last Post: iamwithstupid
  NameError: name 'L2' is not defined soshelby 5 162 Nov-05-2020, 08:50 PM
Last Post: soshelby
  NameError: name 'target_id' is not defined bhagyashree 7 283 Nov-03-2020, 10:22 AM
Last Post: bhagyashree
  code not working, NameError: name 's' is not defined ridgerunnersjw 4 421 Oct-05-2020, 07:03 PM
Last Post: buran
  Going thru tutorials..."NameError: name 'raw_input' is not defined" hmonnier 4 569 Jul-14-2020, 02:19 PM
Last Post: BitPythoner
  NameError: name 'pins' is not defined glennford49 2 795 Jun-15-2020, 12:20 PM
Last Post: glennford49
  python library not defined in user defined function johnEmScott 2 424 May-30-2020, 04:14 AM
Last Post: DT2000
  [split] NameError: name 'formats' is not defined shobhu123 1 622 May-24-2020, 06:29 PM
Last Post: Skaperen
  NameError: name 'cross_validation' is not defined tmhsa 5 1,787 Apr-21-2020, 08:15 PM
Last Post: DT2000
  NameError: name 'os' is not defined lrpirlet 6 3,449 Apr-01-2020, 08:43 PM
Last Post: buran

Forum Jump:

User Panel Messages

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