0

After upgrading to Python 3.9, i'm getting these errors when running mkdocs serve I'm not a developer. I use MKDocs to build a documentation site and I wanted to upgrade the software, as a result I had to upgrade Python, pip, mkdocs and 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```
OSpecht
  • 1
  • 1
  • If it works with previous Python versions (mkdocs site says it works to 3.8.x) the way for a non-developer is to downgrade to that Python version, or install it in parallel and make sure to call the right version for the tool. – progmatico Nov 02 '20 at 20:17
  • Note that you need Python to run, but you do not need the latest Python to have the tools upgraded. The tools still runs with earlier Python versions (until 3.5.x) – progmatico Nov 02 '20 at 20:19
  • Great, thanks - I downgraded back to Python 3.7 however, the mkdocs serve command is now looking for Python 3.9 ```-bash: /usr/local/bin/mkdocs: /usr/local/opt/python@3.9/bin/python3.9: bad interpreter: No such file or directory``` – OSpecht Nov 02 '20 at 21:07
  • I think that is because the tools were installed with the pip from version 3.9. Try reinstalling the tools with the pip for the 3.7 version. You can also create a soft link from the expected 3.9 to the 3.7, but this may create confusion in future (and I am not sure it is enough). – progmatico Nov 02 '20 at 21:30
  • 1
    For problems like this, that may impact other libraries requiring other Pythons, developers use for example virtualenv, if you want to explore it. It is very easy to use. Then you activate whatever environment you need for each project. – progmatico Nov 02 '20 at 21:33

1 Answers1

0

Try this.

pip install -U mkdocs

I was getting same error. After updated mkdocs it resolved.

hasanaydogar
  • 885
  • 11
  • 24