pyqt4 - Identical Python files, one runs, the other throws a "file not found" error -
i trying replicate/incorporate code found in this tutorial in own pycharm project.
i have 2 files, tempconv.py
, mainwindow.py
, contain identical code.
the former file resides in users/some_user/documents/coding/qt/firstgui
.
latter file in /users/some_user/documents/coding/python/cv-generator
.
file tempconv.ui
, referenced in code, present in both folders.
this code in files. files identical, mainwindow.py
included in pycharm project while tempconv.py
not.
import sys pyqt4 import qtcore, qtgui, uic form_class = uic.loaduitype("tempconv.ui")[0] # load ui class mywindowclass(qtgui.qmainwindow, form_class): def __init__(self, parent=none): qtgui.qmainwindow.__init__(self, parent) self.setupui(self) self.btn_ctof.clicked.connect(self.btn_ctof_clicked) # bind event handlers self.btn_ftoc.clicked.connect(self.btn_ftoc_clicked) # buttons def btn_ctof_clicked(self): # ctof button event handler cel = float(self.editcel.text()) # fahr = cel * 9 / 5.0 + 32 # self.spinfahr.setvalue(int(fahr + 0.5)) # def btn_ftoc_clicked(self): # ftoc button event handler fahr = self.spinfahr.value() # cel = (fahr - 32) * 5.0 / 9 # self.editcel.settext(str(cel)) # app = qtgui.qapplication(sys.argv) mywindow = mywindowclass(none) mywindow.show() app.exec_()
there 4 scenarios, of 1 fails.
run in pycharm run in terminal mainwindow.py error succes tempconv.py succes succes
the error is:
traceback (most recent call last): file "/users/some_user/documents/coding/python/cv-generator/mainwindow.py", line 4, in <module> form_class = uic.loaduitype("tempconv.ui")[0] # load ui file "/opt/local/library/frameworks/python.framework/versions/2.7/lib/python2.7/site-packages/pyqt4/uic/__init__.py", line 208, in loaduitype winfo = compiler.uicompiler().compileui(uifile, code_string, from_imports, resource_suffix) file "/opt/local/library/frameworks/python.framework/versions/2.7/lib/python2.7/site-packages/pyqt4/uic/compiler/compiler.py", line 140, in compileui w = self.parse(input_stream, resource_suffix) file "/opt/local/library/frameworks/python.framework/versions/2.7/lib/python2.7/site-packages/pyqt4/uic/uiparser.py", line 974, in parse document = parse(filename) file "/opt/local/library/frameworks/python.framework/versions/2.7/lib/python2.7/xml/etree/elementtree.py", line 1182, in parse tree.parse(source, parser) file "/opt/local/library/frameworks/python.framework/versions/2.7/lib/python2.7/xml/etree/elementtree.py", line 647, in parse source = open(source, "rb") ioerror: [errno 2] no such file or directory: 'tempconv.ui'
if run python /users/some_user/documents/coding/python/cv-generator/mainwindow.py
in terminal there no problem.
also, this:
machine:~ some_user$ ls /users/some_user/documents/coding/python/cv-generator readme.md functions.pyc mainwindow.py scratch.json tex functions.py input.json read-in.py tempconv.ui
shows file there.
how can find cause of problem , solve it?
Comments
Post a Comment