本文主要是介绍Jupyter Notebook出错提示An error occurred while retrieving package information解决办法,希望对大家解决编程问题提供一定的参考价值,需要的开发者们随着小编来一起学习吧!
出错日志信息:
To access the notebook, open this file in a browser:file:///C:/Users/colda/AppData/Roaming/jupyter/runtime/nbserver-14564-open.htmlOr copy and paste one of these URLs:http://localhost:8888/?token=3c0113e5da07c0b8b8c9de74ffb453c50470ac8cee429bffor 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 _executeresult = method(*self.path_args, **self.path_kwargs)File "D:\Miniconda\envs\jupyter\lib\site-packages\tornado\web.py", line 3290, in wrapperreturn method(self, *args, **kwargs)File "D:\Miniconda\envs\jupyter\lib\site-packages\notebook\base\handlers.py", line 782, in wrapperreturn method(self, *args, **kwargs)File "D:\Miniconda\envs\jupyter\lib\site-packages\nb_conda\handlers.py", line 230, in getdata = searcher.list_available(self)File "D:\Miniconda\envs\jupyter\lib\site-packages\nb_conda\handlers.py", line 197, in list_availableversion = 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 = Nonemax_version_entry = Nonefor entry in entries:version = parse_version(entry.get('version', ''))if max_version is None or version > max_version:max_version = versionmax_version_entry = entrypackages.append(max_version_entry)return sorted(packages, key=lambda entry: entry.get('name'))
修改后
for entries in data.values():max_version = Nonemax_version_entry = Nonefor entry in entries:try:version = parse_version(entry.get('version', ''))except Exception as e:# print(entry.get('name'))continueif max_version is None or version > max_version:max_version = versionmax_version_entry = entryif max_version_entry:packages.append(max_version_entry)return sorted(packages, key=lambda entry: entry.get('name'))
经过测试,成功解决问题
这篇关于Jupyter Notebook出错提示An error occurred while retrieving package information解决办法的文章就介绍到这儿,希望我们推荐的文章对编程师们有所帮助!