1

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?

MatthewMartin
  • 32,326
  • 33
  • 105
  • 164

2 Answers2

0

You need to add the folder with gui.py and start.py to your $PYTHONPATH

jeremyjjbrown
  • 7,772
  • 5
  • 43
  • 55
  • Well... Now it's starting my program when executing the command... Shouldn't "python "C:\Python34\Scripts\pdoc" --html "C:\pathtothefile\script.py"" be correct? –  Jun 24 '15 at 04:00
  • Still starting the program –  Jun 24 '15 at 04:08
  • try just `C:\Python34\Scripts\pdoc --html C:\pathtothefile\script.py` the doc asks for `pdoc --html csv` – jeremyjjbrown Jun 24 '15 at 04:11
  • Are you sure pdoc is at that path? if you are using those quotes, please remove them. you could cd to C:\Python34\Scripts\ and just call `pdoc --html C:\pathtothefile\script.py` – jeremyjjbrown Jun 24 '15 at 04:13
  • I am not using any quotes right now. The error message contained the quotes. And yes, I am sure, that this is the path. The first command that I used (the one from the question) works with the quotes and the "python" at the beginning if my .py file doesn't contain any modules that pdoc can't find. –  Jun 24 '15 at 04:16
  • When I cd to C:\Python34\Scripts\ and try to execute pdoc it still yields the error, that the command "pdoc" can't be found –  Jun 24 '15 at 04:17
  • If I change the content of the start.py to "# -*- coding: utf-8 -*- """just a test""" print('just printing anything') and execute python "C:\Python34\Scripts\pdoc" --html "C:\pathtothefile\script.py" I get my .html file –  Jun 24 '15 at 04:20
0

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.

Michael
  • 67
  • 8