在Python中运行ipython笔记本时出现了文件“&书信电报;stdin>&引用;,第1行语法错误:无效语法

在Python中运行ipython笔记本时出现了文件“&书信电报;stdin>&引用;,第1行语法错误:无效语法,python,Python,我在Max OS中安装了tensorflow+python,并参考了web上的一些资源。 环境参数:Mac OS 10.12+Python 2.7+tensorflow 0.5.0 当我试图打开笔记本时,出现了如下错误: ****MacBook:code ****$ python Python 2.7.12 (v2.7.12:d33e0cf91556, Jun 26 2016, 12:10:39) [GCC 4.2.1 (Apple Inc. build 5666) (dot 3)] on

我在Max OS中安装了tensorflow+python,并参考了web上的一些资源。 环境参数:Mac OS 10.12+Python 2.7+tensorflow 0.5.0 当我试图打开笔记本时,出现了如下错误:

****MacBook:code ****$ python

Python 2.7.12 (v2.7.12:d33e0cf91556, Jun 26 2016, 12:10:39) 
[GCC 4.2.1 (Apple Inc. build 5666) (dot 3)] on darwin
Type "help", "copyright", "credits" or "license" for more information.
>>> ipython notebook
File "<stdin>", line 1
ipython notebook
               ^
SyntaxError: invalid syntax
>>> print  ‘hello'


python[notebook])
使用“打印”命令时,结果是:

>>> print "hello"
    hello
>>> print(hello)
  Traceback (most recent call last):
  File "<stdin>", line 1, in <module>
 NameError: name 'hello' is not defined
 >>> print("hello")
 hello
打印“你好” 你好 >>>打印(您好) 回溯(最近一次呼叫最后一次): 文件“”,第1行,在 NameError:未定义名称“hello” >>>打印(“你好”) 你好 我找不到解决方案,你能给我一些有用的指导吗,非常感谢。

命令“ipython notebook”不是在python REPL中执行的,而是在shell中执行的


**MacBook:code***$ipython notebook
就可以了。

ipython notebook
不是Python命令,所以不应该在Python提示符下键入它。至于第二个问题,您试图在第二种情况下打印名为
hello
的变量,但尚未定义它。您可能应该看看Python教程。非常感谢您的回答。我列出了案例打印(***),只是想解释这个问题与Python不兼容。我卸载Python并使用“sudo easy_install ipython”重新安装它,它可以工作。再次感谢。****MacBook:notebook***$ipython notebook-bash:ipython:command未找到是否需要添加环境变量?是否安装了ipython?您可以使用
pip install ipython
进行安装。
>>> print "hello"
    hello
>>> print(hello)
  Traceback (most recent call last):
  File "<stdin>", line 1, in <module>
 NameError: name 'hello' is not defined
 >>> print("hello")
 hello