【问题标题】:Unable To run mkdocs - theme with the same name无法运行 mkdocs - 同名主题
【发布时间】:2020-05-25 00:34:11
【问题描述】:

我安装了一个主题,然后,当我从命令行运行 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 上运行: 蟒蛇:2.7.15 画中画:20.0.2

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

【问题讨论】:

    标签: pip mkdocs


    【解决方案1】:

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

    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

    【讨论】:

      【解决方案2】:

      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 -kdocspip 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-02-18
        • 1970-01-01
        • 1970-01-01
        • 2014-08-23
        • 1970-01-01
        • 1970-01-01
        • 2022-09-30
        • 1970-01-01
        • 1970-01-01
        相关资源
        最近更新 更多