【问题标题】:Sphinx 1.8 Typerror Metaclass conflict , Python 2.7Sphinx 1.8 Typeerror 元类冲突,Python 2.7
【发布时间】:2019-05-17 23:19:48
【问题描述】:

我正在为我的项目在 python 2.7 中生成 sphinx 1.8 文档。 我有一个继承三个类的类:

class Meta(type(QtGui.QWidget), type(BaseClass)):
    pass

class UI(QWidget, BaseClass, BaseWidget)
    __metaclass__ = Meta

    def __init__(self):
        QtGui.QWidget.__init__(self)
        BaseClass.__init__(self)
        BaseWidget.__init__(self)

Python 应用程序没有错误。

但是使用 sphinx 1.8,会产生以下错误: TypeError:元类冲突:派生类的元类必须是其所有基类的元类的(非严格)子类

有人可以帮忙吗?

【问题讨论】:

    标签: python python-2.7 python-sphinx metaclass


    【解决方案1】:

    问题在于使用 Python 3 而不是 Python 2.7 的 Sphinx。 我有另一个项目在 Python 3 中运行。 为了解决这个错误,Sphinx 必须使用 Python 2.7 版本。 在 ma​​ke.bat 文件中: 删除 if 语句并显式设置 SPHINXBUILD 路径:

    @ECHO OFF
    
    pushd %~dp0
    
    REM Command file for Sphinx documentation
    
    set SPHINXBUILD= "C:\\Python27\\Scripts\\sphinx-build.exe"
    
    set SOURCEDIR=.
    set BUILDDIR=_build
    

    它不会再给元类错误了。

    【讨论】:

      猜你喜欢
      • 2017-12-29
      • 2018-09-23
      • 2021-06-18
      • 1970-01-01
      • 2022-01-12
      • 2017-07-06
      • 2016-08-20
      • 1970-01-01
      • 1970-01-01
      相关资源
      最近更新 更多