我使用以下方式安装了 IPython
sudo apt-get install ipython ipython-notebook
但是当我尝试启动它时,它抱怨没有找到某些组件:
sudo ipython notebook
Traceback (most recent call last):
File "/usr/bin/ipython", line 5, in <module>
start_ipython()
File "/usr/lib/python2.7/dist-packages/IPython/__init__.py", line 120, in start_ipython
return launch_new_instance(argv=argv, **kwargs)
File "/usr/lib/python2.7/dist-packages/IPython/config/application.py", line 564, in launch_instance
app.initialize(argv)
File "<decorator-gen-110>", line 2, in initialize
File "/usr/lib/python2.7/dist-packages/IPython/config/application.py", line 92, in catch_config_error
return method(app, *args, **kwargs)
File "/usr/lib/python2.7/dist-packages/IPython/terminal/ipapp.py", line 321, in initialize
super(TerminalIPythonApp, self).initialize(argv)
File "<decorator-gen-7>", line 2, in initialize
File "/usr/lib/python2.7/dist-packages/IPython/config/application.py", line 92, in catch_config_error
return method(app, *args, **kwargs)
File "/usr/lib/python2.7/dist-packages/IPython/core/application.py", line 381, in initialize
self.parse_command_line(argv)
File "/usr/lib/python2.7/dist-packages/IPython/terminal/ipapp.py", line 316, in parse_command_line
return super(TerminalIPythonApp, self).parse_command_line(argv)
File "<decorator-gen-4>", line 2, in parse_command_line
File "/usr/lib/python2.7/dist-packages/IPython/config/application.py", line 92, in catch_config_error
return method(app, *args, **kwargs)
File "/usr/lib/python2.7/dist-packages/IPython/config/application.py", line 475, in parse_command_line
return self.initialize_subcommand(subc, subargv)
File "<decorator-gen-3>", line 2, in initialize_subcommand
File "/usr/lib/python2.7/dist-packages/IPython/config/application.py", line 92, in catch_config_error
return method(app, *args, **kwargs)
File "/usr/lib/python2.7/dist-packages/IPython/config/application.py", line 406, in initialize_subcommand
subapp = import_item(subapp)
File "/usr/lib/python2.7/dist-packages/IPython/utils/importstring.py", line 42, in import_item
module = __import__(package, fromlist=[obj])
File "/usr/lib/python2.7/dist-packages/IPython/html/notebookapp.py", line 62, 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 97, in <module>
from singledispatch import singledispatch # backport
ImportError: No module named singledispatch
版本信息:
cat /etc/lsb-release
DISTRIB_ID=Ubuntu
DISTRIB_RELEASE=15.10
DISTRIB_CODENAME=wily
DISTRIB_DESCRIPTION="Ubuntu 15.10"
答案1
使用以下命令安装 ipython notebook:
sudo apt-get install ipython ipython-notebook
将自动安装python-tornado
系统范围的(这是一个强制依赖项,请参阅http://packages.ubuntu.com/wily/ipython-notebook)
您遇到singledispatch
导入问题是因为您还在 中手动安装了 tornado 版本/usr/local/lib/python2.7/dist-packages/tornado
。
尝试使用以下命令删除有问题的版本:
sudo rm -rf /usr/local/lib/python2.7/dist-packages/tornado