Jupyter笔记本500:内部服务器E

2024-04-24 11:00:55 发布

您现在位置:Python中文网/ 问答频道 /正文

我想学习如何使用笔记本电脑。到目前为止,我已经成功地下载并安装了它(使用pip),但打开它时遇到了问题。

我通过键入以下内容来打开它:

jupyter notebook

在我的终点站。它将在“我的浏览器”中打开,网址为:

http://localhost:8888/tree

我只得到一个大:

500 : Internal Server Error

信息。有人能告诉我出什么事了吗?

我的终端中的完整错误消息:

[E 17:53:52.034 NotebookApp] Uncaught exception GET /tree (::1)
    HTTPServerRequest(protocol='http', host='localhost:8888', method='GET', uri='/tree', version='HTTP/1.1', remote_ip='::1', headers={'Accept-Language': 'en-US,en;q=0.8,es;q=0.6', 'Accept-Encoding': 'gzip, deflate, sdch', 'Host': 'localhost:8888', 'Accept': 'text/html,application/xhtml+xml,application/xml;q=0.9,image/webp,*/*;q=0.8', 'User-Agent': 'Mozilla/5.0 (Macintosh; Intel Mac OS X 10_7_5) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/49.0.2623.112 Safari/537.36', 'Connection': 'keep-alive', 'Upgrade-Insecure-Requests': '1'})
    Traceback (most recent call last):
      File "/opt/local/Library/Frameworks/Python.framework/Versions/2.7/lib/python2.7/site-packages/tornado/web.py", line 1443, in _execute
        result = method(*self.path_args, **self.path_kwargs)
      File "/opt/local/Library/Frameworks/Python.framework/Versions/2.7/lib/python2.7/site-packages/tornado/web.py", line 2800, in wrapper
        return method(self, *args, **kwargs)
      File "/opt/local/Library/Frameworks/Python.framework/Versions/2.7/lib/python2.7/site-packages/notebook/tree/handlers.py", line 50, in get
        terminals_available=self.settings['terminals_available'],
      File "/opt/local/Library/Frameworks/Python.framework/Versions/2.7/lib/python2.7/site-packages/notebook/base/handlers.py", line 302, in render_template
        template = self.get_template(name)
      File "/opt/local/Library/Frameworks/Python.framework/Versions/2.7/lib/python2.7/site-packages/notebook/base/handlers.py", line 298, in get_template
        return self.settings['jinja2_env'].get_template(name)
      File "/opt/local/Library/Frameworks/Python.framework/Versions/2.7/lib/python2.7/site-packages/Jinja2-2.6-py2.7.egg/jinja2/environment.py", line 719, in get_template
        return self._load_template(name, self.make_globals(globals))
      File "/opt/local/Library/Frameworks/Python.framework/Versions/2.7/lib/python2.7/site-packages/Jinja2-2.6-py2.7.egg/jinja2/environment.py", line 693, in _load_template
        template = self.loader.load(self, name, globals)
      File "/opt/local/Library/Frameworks/Python.framework/Versions/2.7/lib/python2.7/site-packages/Jinja2-2.6-py2.7.egg/jinja2/loaders.py", line 127, in load
        code = environment.compile(source, name, filename)
      File "/opt/local/Library/Frameworks/Python.framework/Versions/2.7/lib/python2.7/site-packages/Jinja2-2.6-py2.7.egg/jinja2/environment.py", line 493, in compile
        self.handle_exception(exc_info, source_hint=source)
      File "/opt/local/Library/Frameworks/Python.framework/Versions/2.7/lib/python2.7/site-packages/notebook/templates/tree.html", line 8, in template
        data-base-url="{{base_url | urlencode}}"
    TemplateAssertionError: no filter named 'urlencode'
[E 17:53:52.819 NotebookApp] {
      "Accept-Language": "en-US,en;q=0.8,es;q=0.6",
      "Accept-Encoding": "gzip, deflate, sdch",
      "Host": "localhost:8888",
      "Accept": "text/html,application/xhtml+xml,application/xml;q=0.9,image/webp,*/*;q=0.8",
      "User-Agent": "Mozilla/5.0 (Macintosh; Intel Mac OS X 10_7_5) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/49.0.2623.112 Safari/537.36",
      "Connection": "keep-alive",
      "Upgrade-Insecure-Requests": "1"
    }
[E 17:53:52.819 NotebookApp] 500 GET /tree (::1) 874.29ms referer=None

编辑

尝试按建议更新ipython时,生成以下错误消息:

Exception:
Traceback (most recent call last):
  File "/opt/local/Library/Frameworks/Python.framework/Versions/2.7/lib/python2.7/site-packages/pip/basecommand.py", line 209, in main
    status = self.run(options, args)
  File "/opt/local/Library/Frameworks/Python.framework/Versions/2.7/lib/python2.7/site-packages/pip/commands/install.py", line 317, in run
    prefix=options.prefix_path,
  File "/opt/local/Library/Frameworks/Python.framework/Versions/2.7/lib/python2.7/site-packages/pip/req/req_set.py", line 732, in install
    **kwargs
  File "/opt/local/Library/Frameworks/Python.framework/Versions/2.7/lib/python2.7/site-packages/pip/req/req_install.py", line 835, in install
    self.move_wheel_files(self.source_dir, root=root, prefix=prefix)
  File "/opt/local/Library/Frameworks/Python.framework/Versions/2.7/lib/python2.7/site-packages/pip/req/req_install.py", line 1030, in move_wheel_files
    isolated=self.isolated,
  File "/opt/local/Library/Frameworks/Python.framework/Versions/2.7/lib/python2.7/site-packages/pip/wheel.py", line 247, in move_wheel_files
    prefix=prefix,
  File "/opt/local/Library/Frameworks/Python.framework/Versions/2.7/lib/python2.7/site-packages/pip/locations.py", line 142, in distutils_scheme
    i = d.get_command_obj('install', create=True)
  File "/opt/local/Library/Frameworks/Python.framework/Versions/2.7/lib/python2.7/distutils/dist.py", line 845, in get_command_obj
    klass = self.get_command_class(command)
  File "/opt/local/Library/Frameworks/Python.framework/Versions/2.7/lib/python2.7/site-packages/setuptools/dist.py", line 430, in get_command_class
    self.cmdclass[command] = cmdclass = ep.load()
  File "/opt/local/Library/Frameworks/Python.framework/Versions/2.7/lib/python2.7/site-packages/pkg_resources/__init__.py", line 2229, in load
    return self.resolve()
  File "/opt/local/Library/Frameworks/Python.framework/Versions/2.7/lib/python2.7/site-packages/pkg_resources/__init__.py", line 2235, in resolve
    module = __import__(self.module_name, fromlist=['__name__'], level=0)
ImportError: No module named command.install

Tags: inpyselflibpackageslocallinelibrary
3条回答

也有类似的问题。用这个命令升级ipython后修复了这个问题

sudo pip install --upgrade "ipython[all]"

注意:确保使用双引号和[all]键入ipython

尝试先升级jupyter hub

pip install --upgrade jupyterhub


pip install --upgrade --user nbconvert

在windows 10上也为我工作过。

升级nbconvert包对我有效。pip install --upgrade --user nbconvert

相关问题 更多 >