2016-04-25 140 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:內部服務器錯誤是固定的。