在最近的升级中,当使用SyntaxError: invalid syntax
启动笔记本的python2.7实例时,我正遇到$ ipython2 notebook
的严重问题。
错误似乎来自使用tornado
的{{1}},并且在该库中有python3.4语法。
我可以从ayncio
开始,但我正在使用的$ ipython3 notebook
使用mayavi
,我相信它仍然只用于python2。
令人讨厌的错误消息是:
$ ipython2 notebook
Traceback (most recent call last):
File "/usr/local/bin/ipython2", line 11, in <module>
sys.exit(start_ipython())
File "/usr/local/lib/python2.7/dist-packages/IPython/__init__.py", line 118, in start_ipython
return launch_new_instance(argv=argv, **kwargs)
File "/usr/local/lib/python2.7/dist-packages/traitlets/config/application.py", line 591, in launch_instance
app.initialize(argv)
File "<string>", line 2, in initialize
File "/usr/local/lib/python2.7/dist-packages/traitlets/config/application.py", line 75, in catch_config_error
return method(app, *args, **kwargs)
File "/usr/local/lib/python2.7/dist-packages/IPython/terminal/ipapp.py", line 305, in initialize
super(TerminalIPythonApp, self).initialize(argv)
File "<string>", line 2, in initialize
File "/usr/local/lib/python2.7/dist-packages/traitlets/config/application.py", line 75, in catch_config_error
return method(app, *args, **kwargs)
File "/usr/local/lib/python2.7/dist-packages/IPython/core/application.py", line 386, in initialize
self.parse_command_line(argv)
File "/usr/local/lib/python2.7/dist-packages/IPython/terminal/ipapp.py", line 300, in parse_command_line
return super(TerminalIPythonApp, self).parse_command_line(argv)
File "<string>", line 2, in parse_command_line
File "/usr/local/lib/python2.7/dist-packages/traitlets/config/application.py", line 75, in catch_config_error
return method(app, *args, **kwargs)
File "/usr/local/lib/python2.7/dist-packages/traitlets/config/application.py", line 487, in parse_command_line
return self.initialize_subcommand(subc, subargv)
File "<string>", line 2, in initialize_subcommand
File "/usr/local/lib/python2.7/dist-packages/traitlets/config/application.py", line 75, in catch_config_error
return method(app, *args, **kwargs)
File "/usr/local/lib/python2.7/dist-packages/traitlets/config/application.py", line 418, in initialize_subcommand
subapp = import_item(subapp)
File "/usr/local/lib/python2.7/dist-packages/ipython_genutils/importstring.py", line 31, in import_item
module = __import__(package, fromlist=[obj])
File "/usr/local/lib/python2.7/dist-packages/notebook/notebookapp.py", line 48, in <module>
from tornado import httpserver
File "/usr/local/lib/python2.7/dist-packages/tornado/httpserver.py", line 34, in <module>
from tornado.http1connection import HTTP1ServerConnection, HTTP1ConnectionParameters
File "/usr/local/lib/python2.7/dist-packages/tornado/http1connection.py", line 28, in <module>
from tornado import gen
File "/usr/local/lib/python2.7/dist-packages/tornado/gen.py", line 1236, in <module>
import tornado.platform.asyncio
File "/usr/local/lib/python2.7/dist-packages/tornado/platform/asyncio.py", line 33, in <module>
import asyncio
File "/usr/local/lib/python2.7/dist-packages/asyncio/__init__.py", line 9, in <module>
from . import selectors
File "/usr/local/lib/python2.7/dist-packages/asyncio/selectors.py", line 39
"{!r}".format(fileobj)) from None
^
SyntaxError: invalid syntax
对我的作品有什么帮助?降级龙卷风?我的设置有问题吗?为什么可以在python2.7下安装asyncio?
答案 0 :(得分:7)
降级龙卷风的工作原理:
$ sudo pip install tornado==4.1
$ ipython2 notebook
[I 17:22:31.800 NotebookApp] Serving notebooks from local directory: /home/fnielsen/fnielsen/ipynb
...