MKDocs Serve中的Python 3.9错误

hc2pp10m  于 2023-02-01  发布在  Python
关注(0)|答案(1)|浏览(204)

升级到Python 3.9后,我在运行mkdocs serve时遇到这些错误我不是开发人员,我使用MKDocs来建立一个文档站点,我想升级软件,结果我不得不升级Python,pip,mkdocs和mkdocs-material。

INFO    -  Cleaning site directory 
Traceback (most recent call last):
  File "/usr/local/bin/mkdocs", line 8, in <module>
    sys.exit(cli())
  File "/usr/local/lib/python3.9/site-packages/click/core.py", line 829, in __call__
    return self.main(*args, **kwargs)
  File "/usr/local/lib/python3.9/site-packages/click/core.py", line 782, in main
    rv = self.invoke(ctx)
  File "/usr/local/lib/python3.9/site-packages/click/core.py", line 1259, in invoke
    return _process_result(sub_ctx.command.invoke(sub_ctx))
  File "/usr/local/lib/python3.9/site-packages/click/core.py", line 1066, in invoke
    return ctx.invoke(self.callback, **ctx.params)
  File "/usr/local/lib/python3.9/site-packages/click/core.py", line 610, in invoke
    return callback(*args, **kwargs)
  File "/usr/local/lib/python3.9/site-packages/mkdocs/__main__.py", line 133, in serve_command
    serve.serve(
  File "/usr/local/lib/python3.9/site-packages/mkdocs/commands/serve.py", line 141, in serve
    config = builder()
  File "/usr/local/lib/python3.9/site-packages/mkdocs/commands/serve.py", line 136, in builder
    build(config, live_server=live_server, dirty=dirty)
  File "/usr/local/lib/python3.9/site-packages/mkdocs/commands/build.py", line 263, in build
    nav = get_navigation(files, config)
  File "/usr/local/lib/python3.9/site-packages/mkdocs/structure/nav.py", line 102, in get_navigation
    items = _data_to_navigation(nav_config, files, config)
  File "/usr/local/lib/python3.9/site-packages/mkdocs/structure/nav.py", line 157, in _data_to_navigation
    return [
  File "/usr/local/lib/python3.9/site-packages/mkdocs/structure/nav.py", line 158, in <listcomp>
    _data_to_navigation(item, files, config)[0]
  File "/usr/local/lib/python3.9/site-packages/mkdocs/structure/nav.py", line 150, in _data_to_navigation
    return [
  File "/usr/local/lib/python3.9/site-packages/mkdocs/structure/nav.py", line 153, in <listcomp>
    Section(title=key, children=_data_to_navigation(value, files, config))
  File "/usr/local/lib/python3.9/site-packages/mkdocs/structure/nav.py", line 164, in _data_to_navigation
    file = files.get_file_from_path(path)
  File "/usr/local/lib/python3.9/site-packages/mkdocs/structure/files.py", line 31, in get_file_from_path
    return self.src_paths.get(os.path.normpath(path))
  File "/usr/local/Cellar/python@3.9/3.9.0_1/Frameworks/Python.framework/Versions/3.9/lib/python3.9/posixpath.py", line 336, in normpath
    path = os.fspath(path)
TypeError: expected str, bytes or os.PathLike object, not NoneType```
k97glaaz

k97glaaz1#

试试这个。

pip install -U mkdocs

我得到同样的错误。更新mkdocs后解决。

相关问题