1

我安装了一个主题,这样做之后,当我从命令行运行 mkdocs 命令时,我收到以下错误:

Traceback (most recent call last):
  File "/usr/local/bin/mkdocs", line 5, in <module>
    from mkdocs.__main__ import cli
  File "/usr/local/lib/python2.7/site-packages/mkdocs/__main__.py", line 78, in <module>
    theme_choices = utils.get_theme_names()
  File "/usr/local/lib/python2.7/site-packages/mkdocs/utils/__init__.py", line 413, in get_theme_names
    return get_themes().keys()
  File "/usr/local/lib/python2.7/site-packages/mkdocs/utils/__init__.py", line 397, in get_themes
    "with the same name".format(theme.name, theme.dist.key))
mkdocs.exceptions.ConfigurationError: The theme readthedocs is a builtin theme but -kdocs provides a theme with the same name

我在 mac 上运行:Python:2.7.15 PIP:20.0.2

任何有关如何解决此错误的建议将不胜感激。

4

2 回答 2

0

Waylan 提供的信息是正确的,-kdocs应该删除该包。这是一些附加信息。

mkdocs.exceptions.ConfigurationError: The theme readthedocs is a builtin theme but -kdocs provides a theme with the same name

如果您运行$ pip list,您可能会看到类似以下内容。mkdocs是一个定期安装的包,-kdocs而是一个因删除失败而重命名的包。删除是安全的-kdocs

Package                        Version
------------------------------ ----------
-kdocs                         1.1.2
mkdocs                         1.1.2

但是,如果您运行pip uninstall -kdocsor pip uninstall "-kdocs",您可能会收到以下错误:

$ pip uninstall "-kdocs"

Usage:   
  pip uninstall [options] <package> ...
  pip uninstall [options] -r <requirements file> ...

no such option: -k

pip uninstall您可以直接从文件系统中删除包,而不是使用。

如果您列出您的site-packages目录,您可能会看到一个命名如下的子目录。请注意,这以波浪号~而不是连字符开头-

~kdocs-1.1.2.dist-info

所以使用:

$ cd /path/to/site-packages
$ ls
$ rm -rf ~kdocs-1.1.2.dist-info
于 2021-03-03T11:16:12.990 回答
0

最后一行的错误消息解释了这个问题:

mkdocs.exceptions.ConfigurationError: The theme readthedocs is a builtin theme but -kdocs provides a theme with the same name

MkDocs 包含一个名为readthedocs. 并且保留了内置主题名称。但是,MkDocs 检测到另一个包已将具有相同保留名称的主题注册到该mkdocs.themes组。显然,该包名为-kdocs,这很奇怪,因为 python 包通常不会以连字符 ( -) 开头。

无论如何,解决方案是删除带有非法主题名称的包。如果您最近安装了任何第三方主题,请尝试将它们一一卸载,直到使用要卸载的软件包名称的命令停止pip uninstall packagename出现错误为止。packagename对于所有已安装软件包的列表,您可以使用pip freeze.

于 2020-02-11T03:59:08.997 回答