gpt4 book ai didi

python-2.7 - 使用 ipython notebook 获取 "SyntaxError: invalid syntax"

转载 作者:行者123 更新时间:2023-12-04 14:25:45 29 4
gpt4 key购买 nike

通过最近的升级,我现在遇到了 SyntaxError: invalid syntax 的严重问题。使用 $ ipython2 notebook 启动笔记本的 python2.7 实例时.

该错误似乎源于 tornado使用 ayncio在那个库中有 python3.4 语法。

我可以从 $ 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

什么对我的网站有帮助?降级 Tornado ?我的设置有问题吗。为什么在python2.7下完全可以安装asyncio?

最佳答案

降级 Tornado 作品:

$ sudo pip install tornado==4.1
$ ipython2 notebook
[I 17:22:31.800 NotebookApp] Serving notebooks from local directory: /home/fnielsen/fnielsen/ipynb
...

关于python-2.7 - 使用 ipython notebook 获取 "SyntaxError: invalid syntax",我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/34206803/

29 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com