Python终端错误

时间:2013-09-14 15:55:19

标签: python

只是想知道我该如何解决这个错误?

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

另一个例子:

python --version
Traceback (most recent call last):
  File "<stdin>", line 1, in <module>
NameError: name 'python' is not define

2 个答案:

答案 0 :(得分:3)

命令python在命令提示符下运行。 python不是Python中的命令。

打开命令提示符(在Windows上名为cmd,在OSX上名为Terminal),然后键入您尝试使用的命令之一。

C:\>python
Python 2.7.2 (default, Jun 12 2011, 15:08:59) [MSC v.1500 32 bit (Intel)] on win32
Type "help", "copyright", "credits" or "license" for more information.

>>> print 'test'
test
>>> exit()

C:\>python --version
Python 2.7.2

C:\>

答案 1 :(得分:3)

你得到一个Python错误;这意味着你已经 in Python解释器。因此,您不需要(或甚至可以)再次执行Python可执行文件。

如果要退出解释器,请按 Ctrl + Z Enter 。然后,您就可以再次致电pythonpython --version