2015-07-20 129 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