出错日志信息:
To access the notebook, open this file in a browser:
file:///C:/Users/colda/AppData/Roaming/jupyter/runtime/nbserver-14564-open.html
Or copy and paste one of these URLs:
http://localhost:8888/?token=3c0113e5da07c0b8b8c9de74ffb453c50470ac8cee429bff
or http://127.0.0.1:8888/?token=3c0113e5da07c0b8b8c9de74ffb453c50470ac8cee429bff
[E 13:39:33.298 NotebookApp] Uncaught exception GET /conda/packages/available?_=1710567542007 (::1)
HTTPServerRequest(protocol='http', host='localhost:8888', method='GET', uri='/conda/packages/available?_=1710567542007', version='HTTP/1.1', remote_ip='::1')
Traceback (most recent call last):
File "D:\Miniconda\envs\jupyter\lib\site-packages\tornado\web.py", line 1784, in _execute
result = method(*self.path_args, **self.path_kwargs)
File "D:\Miniconda\envs\jupyter\lib\site-packages\tornado\web.py", line 3290, in wrapper
return method(self, *args, **kwargs)
File "D:\Miniconda\envs\jupyter\lib\site-packages\notebook\base\handlers.py", line 782, in wrapper
return method(self, *args, **kwargs)
File "D:\Miniconda\envs\jupyter\lib\site-packages\nb_conda\handlers.py", line 230, in get
data = searcher.list_available(self)
File "D:\Miniconda\envs\jupyter\lib\site-packages\nb_conda\handlers.py", line 197, in list_available
version = parse_version(entry.get('version', ''))
File "D:\Miniconda\envs\jupyter\lib\site-packages\pkg_resources\_vendor\packaging\version.py", line 198, in __init__
raise InvalidVersion(f"Invalid version: '{version}'")
pkg_resources.extern.packaging.version.InvalidVersion: Invalid version: 'custom'
[W 13:39:33.314 NotebookApp] Unhandled error
[E 13:39:33.314 NotebookApp] {
"Host": "localhost:8888",
"Accept": "application/json, text/javascript, */*; q=0.01",
"Referer": "http://localhost:8888/tree",
"User-Agent": "Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/122.0.0.0 Safari/537.36 Edg/122.0.0.0"
}
[E 13:39:33.314 NotebookApp] 500 GET /conda/packages/available?_=1710567542007 (::1) 501.660000ms referer=http://localhost:8888/tree
分析是package版本解析时遇到了问题了
解决方法:
将这个路径下的 handlers.py 代码进行修改,各人的安装路径不同,对照自己的路径找一下
D:\Miniconda\pkgs\nb_conda-2.2.1-py38_1\Lib\site-packages\nb_conda\handlers.py
修改前
for entries in data.values():
max_version = None
max_version_entry = None
for entry in entries:
version = parse_version(entry.get('version', ''))
if max_version is None or version > max_version:
max_version = version
max_version_entry = entry
packages.append(max_version_entry)
return sorted(packages, key=lambda entry: entry.get('name'))
修改后
for entries in data.values():
max_version = None
max_version_entry = None
for entry in entries:
try:
version = parse_version(entry.get('version', ''))
except Exception as e:
# print(entry.get('name'))
continue
if max_version is None or version > max_version:
max_version = version
max_version_entry = entry
if max_version_entry:
packages.append(max_version_entry)
return sorted(packages, key=lambda entry: entry.get('name'))
经过测试,成功解决问题