2016-04-25 27 views
4

我想了解如何使用Jupyter Notebook。到目前为止,我已经设法下载并安装它(使用pip),但我无法打开它。在我的终端Jupyter笔记本500:内部服务器错误

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 

EDIT

当试图更新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 
+0

第二个错误提示您的Python安装有些错误。 –

+1

考虑一直使用Python虚拟环境,它将为您节省大量时间。 ;-)看看[virtualenvwrapper](https://virtualenvwrapper.readthedocs.org/en/latest/)或[miniconda](http://conda.pydata.org/docs/install/quick.html)。 – Peque

回答

4

当时有类似的问题。升级IPython中使用此命令

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

注后修正它:确保用双引号键入IPython的和[all]

+0

谢谢。我试图做到这一点。它开始更新,但我收到了一条错误消息,我将添加为我的主帖的编辑。 – user1551817

+1

尝试卸载并重新安装ipytohn,它与其他软件包有一些冲突。如果你可以有一个更清晰的错误信息版本(可能是截图) –

+1

也许'pip install --upgrade jupyter'更好。 :-) – Peque

3

我也遇到了这个问题。在我的情况下,根本原因是我已经有Jinja2安装了根权限(在我知道更好之前使用了sudo pip install)。

我的解决方案是卸载Jinja2与sudo pip uninstall(这是必需的,因为它安装了根权限),并重新运行pip install jupyter重新安装它与常规用户权限。

$ sudo pip uninstall Jinja2 
$ pip install jupyter 

在使用sudo在这里安装工程,它使从长远来看问题更严重,因为它的所有包都用root权限安装,导致这样在未来与其他产品进行进一步的问题。这有点像踢,可以在路上。

许多人不会在乎,只要它有效。但对于那些我认为我会提及的人。

无法确切知道有问题的软件包是什么,但它可能是堆栈跟踪中的一个。我注意到Jinja2是我在Python初期隐约记得的,所以我从那里开始并且工作。

+0

'pip install --user'可能是你想要的命令。这样,pip将本地安装到用户,并且不需要管理员权限。 – scicalculator

0

我有同样的问题,我的解决方案是更新Jinja2包到版本Jinja2-2.8。

要更新它,我用的easy_install命令如下:

sudo easy_install -U python-jinja2[all] 

在此之后,500:内部服务器错误是固定的。