PyQt4 import fails on debugger

Hello all,

I have started using PyCharm quite seriously as my IDE recently and I must say it is excellent. I have run into some problems while trying to run in debug mode however.

When I run my application using run, everything is fine. But when I try to run it in debug mode I get the following error:

Traceback (most recent call last):
  File "C:\Program Files (x86)\JetBrains\PyCharm Community Edition 139.1485\helpers\pydev\", line 2217, in <module>
    globals =['file'], None, None)
  File "C:\Program Files (x86)\JetBrains\PyCharm Community Edition 139.1485\helpers\pydev\", line 1643, in run
    pydev_imports.execfile(file, globals, locals)  # execute the script
  File "D:/projects/Tools/UnitManager/scripts/", line 16, in <module>
    from PyQt4 import QtGui
ImportError: DLL load failed: The specified procedure could not be found.

I have tried appending my system paths, and os environ paths but no luck at all. Here is my main script that it is crashing on.

import sys
import os
import PyQt4
dirname = os.path.dirname(sys.executable)
qtconf = os.path.join(dirname, "qt.conf")
os.environ["PATH"] += ";" + os.path.dirname(PyQt4.__file__)

print os.environ["PATH"]
print "qt.conf OK", qtconf if os.path.isfile(qtconf) else "qt.conf MISSING"

print "Exectuable is:", sys.executable

from PyQt4 import QtGui
from UnitManager.scripts.window_setup import MainWindowSetup

def main():
    app = QtGui.QApplication(sys.argv)
    MainWindow = MainWindowSetup()

if __name__=="__main__":

Is PyCharm running a different environment when in debug mode or am I missing something crucial?



Please sign in to leave a comment.