Working on my first attempt with QGIS QT Designer I am trying to compile my UI file. I am using Python27 found inside my QGIS installation (purposely not using QGIS v3 at this point). I am using the following command:

C:\Users\username.qgis2\python\plugins\projectfolder>"C:\QGIS\bin\python.exe" "C:\QGIS\apps\Python27\lib\site-packages\PyQt4\uic\pyuic.py" -x ui_testproject.ui -o ui_testproject.py

However, I am getting the following error message in the command prompt:

Traceback (most recent call last):

File "C:\QGIS\apps\Python27\lib\site-packages\PyQt4\uic\pyuic.py", line 31, in from PyQt4 import QtCore ImportError: DLL load failed: The specified module could not be found.

I don’t see a QtCore.dll file (is there even one?), or is it just looking for QtCore? So I take it this may me an environment variable issue? So I have added:

PYTHONHOME C:\QGIS\apps\Python27

PYTHONPATH C:\QGIS\apps\Python27\Lib\site-packages\PyQt4; C:\QGIS\apps\Python27\Scripts

Even added .SPC and .PYD as part of PATHEXT What is missing? What am I doing incorrect?


I wanted to post my solution to this after several weeks of researching and testing. This issue seems to pop up a lot under various conditions so if this helps another beginner, well glad I could contribute.

It did end up being environment variables causing the process not to complete. I have QGIS 2.18 installed at C:\QGIS so for user variables I use:

C:\QGIS\bin\; C:\QGIS\apps\Python27\Scripts\

For system variables I used the following: Path %PYTHONHOME%;%PATH% PYTHONHOME C:\QGIS\apps\Python27; PYTHONPATH C:\QGIC\apps\Python27\Lib; C:\QGIS\apps\Python27\Lib\site-packages\PyQt4;

I then could use the following in my Command prompt: C:\path of where my ui file is> pyuic4 -x projectfile.ui -o projectfile.py

.py file was created.

| improve this answer | |
  • You may use OSGeo4W shell to set your environment. – Zoltan Apr 18 at 7:38

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.