简体   繁体   中英

pdoc - No module named xxx

I am trying to create a normal.html file with pdoc, but I'm getting a error message.

File 1: gui.py

# -*- coding: utf-8 -*-
"""gui test"""

# Form implementation generated from reading ui file 'gui.ui'
#
# Created by: PyQt4 UI code generator 4.11.4
#
# WARNING! All changes made in this file will be lost!

from PyQt4 import QtCore, QtGui

try:
    _fromUtf8 = QtCore.QString.fromUtf8
except AttributeError:
    def _fromUtf8(s):
        return s

try:
    _encoding = QtGui.QApplication.UnicodeUTF8
    def _translate(context, text, disambig):
        return QtGui.QApplication.translate(context, text, disambig, _encoding)
except AttributeError:
    def _translate(context, text, disambig):
        return QtGui.QApplication.translate(context, text, disambig)

class Ui_MainWindow(object):
    """gui test again"""
    def setupUi(self, MainWindow):
        MainWindow.setObjectName(_fromUtf8("MainWindow"))
        MainWindow.resize(800, 600)
        self.centralwidget = QtGui.QWidget(MainWindow)
        self.centralwidget.setObjectName(_fromUtf8("centralwidget"))
        MainWindow.setCentralWidget(self.centralwidget)
        self.menubar = QtGui.QMenuBar(MainWindow)
        self.menubar.setGeometry(QtCore.QRect(0, 0, 800, 21))
        self.menubar.setObjectName(_fromUtf8("menubar"))
        MainWindow.setMenuBar(self.menubar)
        self.statusbar = QtGui.QStatusBar(MainWindow)
        self.statusbar.setObjectName(_fromUtf8("statusbar"))
        MainWindow.setStatusBar(self.statusbar)

        self.retranslateUi(MainWindow)
        QtCore.QMetaObject.connectSlotsByName(MainWindow)

    def retranslateUi(self, MainWindow):
        MainWindow.setWindowTitle(_translate("MainWindow", "MainWindow", None))

File 2: start.py

# -*- coding: utf-8 -*-
"""just a test"""

import sys
from PyQt4 import QtCore, QtGui
from gui import Ui_MainWindow



class StartQT4(QtGui.QMainWindow):
    "just testing again"
    def __init__(self, parent=None):
        QtGui.QWidget.__init__(self, parent)
        self.ui = Ui_MainWindow()
        self.ui.setupUi(self)


app = QtGui.QApplication(sys.argv)
myapp = StartQT4()
myapp.show()

sys.exit(app.exec_())

And I am trying to execute:

python "C:\Python34\Scripts\pdoc" --html "C:\pathtothefile\script.py"

and get the message:

File "C:\pathtothefile\script.py", line 6, in <module> 
from gui import Ui_MainWindow
ImportError: No module named 'gui'

gui.py is in the same folder like start.py. How can I tell pdoc that this is the case?

您需要将包含gui.py和start.py的文件夹添加到$ PYTHONPATH中

For me at least, it said the file was missing until I added a

if __name__ == "__main__":

check to the file, no idea why this is required.

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM