2015-07-20 78 views
-3

我对python相当陌生。我从字面上学习过程。我知道这听起来很愚蠢,但任何帮助将不胜感激。 我对终端类型的Python,我有此错误:无法在Mac上运行python

NameError: name 'python' is not defined 

我要安装或卸载软件包。我输入PIP安装matplotlib 我得到这个错误:

SyntaxError: invalid syntax 

非常感谢!

+0

这与编程python无关,但要在mac上安装python –

+0

您已经启动了一个解释器 –

+0

您已*运行Python * - 您需要'exit()'返回终端! – jonrsharpe

回答

2

它看起来像你正试图在Python解释器中运行python,而不是命令提示符

$ python 
Python 2.7.6 (default, Sep 9 2014, 15:04:36) 
[GCC 4.2.1 Compatible Apple LLVM 6.0 (clang-600.0.39)] on darwin 
Type "help", "copyright", "credits" or "license" for more information. 
>>> python 
Traceback (most recent call last): 
    File "<stdin>", line 1, in <module> 
NameError: name 'python' is not defined 
>>> pip install matplotlib 
    File "<stdin>", line 1 
    pip install matplotlib 
      ^
SyntaxError: invalid syntax 

类型quit()Ctrl+D从Python解释器退出,那么你可以做的pip install

+0

它的工作谢谢你! – Denis