不能 运行 python 在 Mac

Can't run python on Mac

我对 python.I 还很陌生,我确实在学习过程中。我知道这听起来很愚蠢,但我们将不胜感激。 我在终端上输入 python,我遇到了这个错误:

NameError: name 'python' is not defined

我想安装或卸载软件包。我输入了 pip install matplotlib 我收到此错误:

SyntaxError: invalid syntax

非常感谢!

看起来您正试图在 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,等等