gpt4 book ai didi

python - 软件包升级后 Jupyter Notebook 无法工作

转载 作者:行者123 更新时间:2023-12-01 00:18:48 27 4
gpt4 key购买 nike

我创建了一个新的虚拟环境,并通过运行 pipenv install jupyter 安装了 jupyter 笔记本。我现在无法运行 jupyter notebook:

Traceback (most recent call last):
File "c:\users\user\.virtualenvs\jupyter_project-rx9grp37\lib\site-packages\jsonschema\__init__.py", line 31, in <module>
from importlib import metadata
ImportError: cannot import name 'metadata' from 'importlib' (C:\anaconda\Lib\importlib\__init__.py)

During handling of the above exception, another exception occurred:

Traceback (most recent call last):
File "C:\anaconda\Lib\runpy.py", line 193, in _run_module_as_main
"__main__", mod_spec)
File "C:\anaconda\Lib\runpy.py", line 85, in _run_code
exec(code, run_globals)
File "C:\Users\user\.virtualenvs\jupyter_project-RX9gRp37\Scripts\jupyter-notebook.EXE\__main__.py", line 4, in <module>
File "c:\users\user\.virtualenvs\jupyter_project-rx9grp37\lib\site-packages\notebook\notebookapp.py", line 80, in <module>
from .services.contents.manager import ContentsManager
File "c:\users\user\.virtualenvs\jupyter_project-rx9grp37\lib\site-packages\notebook\services\contents\manager.py", line 17, in <module>
from nbformat import sign, validate as validate_nb, ValidationError
File "c:\users\user\.virtualenvs\jupyter_project-rx9grp37\lib\site-packages\nbformat\__init__.py", line 33, in <module>
from .validator import validate, ValidationError
File "c:\users\user\.virtualenvs\jupyter_project-rx9grp37\lib\site-packages\nbformat\validator.py", line 12, in <module>
from jsonschema import ValidationError
File "c:\users\user\.virtualenvs\jupyter_project-rx9grp37\lib\site-packages\jsonschema\__init__.py", line 33, in <module>
import importlib_metadata as metadata
File "c:\users\user\.virtualenvs\jupyter_project-rx9grp37\lib\site-packages\importlib_metadata\__init__.py", line 547, in <module>
__version__ = version(__name__)
File "c:\users\user\.virtualenvs\jupyter_project-rx9grp37\lib\site-packages\importlib_metadata\__init__.py", line 509, in version
return distribution(distribution_name).version
File "c:\users\user\.virtualenvs\jupyter_project-rx9grp37\lib\site-packages\importlib_metadata\__init__.py", line 482, in distribution
return Distribution.from_name(distribution_name)
File "c:\users\user\.virtualenvs\jupyter_project-rx9grp37\lib\site-packages\importlib_metadata\__init__.py", line 183, in from_name
dist = next(dists, None)
File "c:\users\user\.virtualenvs\jupyter_project-rx9grp37\lib\site-packages\importlib_metadata\__init__.py", line 452, in <genexpr>
return (item for item in root.iterdir()
File "C:\anaconda\Lib\pathlib.py", line 1090, in iterdir
for name in self._accessor.listdir(self):
FileNotFoundError: [WinError 3] The system cannot find the path specified: 'C:\\Users\\user\\Documents\\Python\\jupyter_project\\ '

我正在运行 python 3.7。

该问题似乎是由 jsonschema 工作方式最近发生的变化引起的。在 3.0.2 版本中,它似乎按预期工作。

改变的是这个(jsonschema/__init__.py):

之前:

from pkg_resources import get_distribution
__version__ = get_distribution(__name__).version

之后:

try:
from importlib import metadata
except ImportError: # for Python<3.8
import importlib_metadata as metadata
__version__ = metadata.version("jsonschema")

除了降级到 jsonschema==3.0.2 之外,还有其他方法可以解决此问题吗?

谢谢

最佳答案

升级您环境中的 jsonschema 版本

在conda环境中conda 升级 jsonschema

在pip环境下pip install --upgrade jsonschema

这对我有用!

关于python - 软件包升级后 Jupyter Notebook 无法工作,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/59101246/

27 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com