安装后anaconda 2.0.1 amd64在我的 Windows7 上,启动 ipython-notebook 时出现以下错误:
ERROR:tornado.application:Uncaught exception GET /static/components/jquery-ui/th
emes/smoothness/jquery-ui.min.css?v=60f0405edd95e7135ec6a0bbc36d1385 (127.0.0.1)
HTTPRequest(protocol='http', host='localhost:8888', method='GET', uri='/static/c
omponents/jquery-ui/themes/smoothness/jquery-ui.min.css?v=60f0405edd95e7135ec6a0
bbc36d1385', version='HTTP/1.1', remote_ip='127.0.0.1', headers={'Accept-Languag
e': 'zh-CN,zh;q=0.8,en;q=0.6', 'Accept-Encoding': 'gzip,deflate,sdch', 'X-Forwar
ded-For': '211.166.224.142', 'Host': 'localhost:8888', 'Accept': 'text/css,*/*;q
=0.1', 'User-Agent': 'Mozilla/5.0 (Windows NT 6.1) AppleWebKit/537.36 (KHTML, li
ke Gecko) Chrome/33.0.1750.154 Safari/537.36', 'Connection': 'keep-alive', 'Refe
rer': 'http://localhost:8888/tree'})
Traceback (most recent call last):
File "C:\Anaconda\lib\site-packages\tornado\web.py", line 1270, in _when_compl
ete
callback()
File "C:\Anaconda\lib\site-packages\tornado\web.py", line 1291, in _execute_me
thod
self._when_complete(method(*self.path_args, **self.path_kwargs),
File "C:\Anaconda\lib\site-packages\tornado\web.py", line 1954, in get
self.set_headers()
File "C:\Anaconda\lib\site-packages\tornado\web.py", line 2032, in set_headers
content_type = self.get_content_type()
File "C:\Anaconda\lib\site-packages\tornado\web.py", line 2210, in get_content
_type
mime_type, encoding = mimetypes.guess_type(self.absolute_path)
File "C:\Anaconda\lib\mimetypes.py", line 287, in guess_type
init()
File "C:\Anaconda\lib\mimetypes.py", line 348, in init
db.read_windows_registry()
File "C:\Anaconda\lib\mimetypes.py", line 256, in read_windows_registry
with _winreg.OpenKey(hkcr, subkeyname) as subkey:
WindowsError: [Error 2]
ERROR:tornado.access:{
"Accept-Language": "zh-CN,zh;q=0.8,en;q=0.6",
"Accept-Encoding": "gzip,deflate,sdch",
"X-Forwarded-For": "211.166.224.142",
"Connection": "keep-alive",
"Accept": "text/css,*/*;q=0.1",
"User-Agent": "Mozilla/5.0 (Windows NT 6.1) AppleWebKit/537.36 (KHTML, like Ge
cko) Chrome/33.0.1750.154 Safari/537.36",
"Host": "localhost:8888",
"Referer": "http://localhost:8888/tree"
}
完整的回溯is here 。我在网上搜索了一下,发现this post有类似的问题,但仍然无法解决我的问题——文件mimetypes.py
似乎已被更改。
我尝试更改 mimetypes.py
中的函数 enum_types
中的代码:
try:
ctype = _winreg.EnumKey(mimedb, i)
except EnvironmentError:
break
至:
try:
ctype = _winreg.EnumKey(mimedb, i)
#except EnvironmentError:
# break
finally:
pass
但运气不好。该错误发生在我一个 friend 的电脑上,很抱歉我无法重现该错误并提供更多详细信息。
最佳答案
我刚刚遇到了同样的问题,请查看我的解决方法:
背后的问题是 subkeyname 变量包含 _winreg.OpenKey 函数不可读的字符串。这可能是由于某些中国软件向注册表添加了非 unicode 值(阿里旺旺是首要嫌疑人)。因此,您需要捕获此类异常并绕过它们。
以下是从第 256 行开始的原始代码:
with _winreg.OpenKey(hkcr, subkeyname) as subkey:
# If there is no "Content Type" value, or if it is not
# a simple string, simply skip
try:
mimetype, datatype = _winreg.QueryValueEx(
subkey, 'Content Type')
except EnvironmentError:
continue
if datatype != _winreg.REG_SZ:
continue
self.add_type(mimetype, subkeyname, strict)
只需添加一个“try:... except” block 即可克服 WindowsError 异常:
try:
with _winreg.OpenKey(hkcr, subkeyname) as subkey:
# If there is no "Content Type" value, or if it is not
# a simple string, simply skip
try:
mimetype, datatype = _winreg.QueryValueEx(
subkey, 'Content Type')
except EnvironmentError:
continue
if datatype != _winreg.REG_SZ:
continue
self.add_type(mimetype, subkeyname, strict)
except EnvironmentError:
continue
这对我有用。希望对您有所帮助。
关于python - 启动 ipython-notebook 时出现 "ERROR:tornado.application:Uncaught exception GET",我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/24661245/