Python Forum
Thread Rating:
  • 0 Vote(s) - 0 Average
  • 1
  • 2
  • 3
  • 4
  • 5
Cannot import QtSql
#1
My program has on line only:
from PyQt4 import QtSql
And in pyCharm it gets underlined with a red line, 'Unresolve reference'

If I make other imports from PyQt4 (e.g: from PyQt4 import QtCore or from PyQt4 import QtGui) they work ok.
Huh
What am I doing wrong?

(Python 3.4 on WinXP)
Reply
#2
I assume you have never loaded PyQt4
pip install PyQt4
Reply
#3
It should be a part PyQt4,i do have many Python version so i have Python 3.4 with PyQt4 installed.
E:\1py_div\xkcd
λ py -3.4
Python 3.4.2 (v3.4.2:ab2c023a9432, Oct  6 2014, 22:15:05) [MSC v.1600 32 bit (Intel)] on win32
Type "help", "copyright", "credits" or "license" for more information.
>>> from PyQt4 import QtSql
>>> QtSql.__file__
'C:\\Python34\\lib\\site-packages\\PyQt4\\QtSql.pyd'
Quote:(Python 3.4 on WinXP)
Should't you be upgrading soon Wink
Could be the problem.
Wheel for PyQt4.
Reply
#4
The PyQt4 that I have installed is from the wheel (installed with pip).

This code runs fine:
from PyQt4 import QtCore, QtGui, uic
But this one doesn't:
from PyQt4 import QtCore, QtGui, uic, QtSql
This is the error:
'from PyQt4 import QtCore, QtGui, uic, QtSql
ImportError: DLL load failed: The specified procedure could not be found.'

In D:\Python34\Lib\site-packages\PyQt4 I see QtSql4.dll.


(I work on Win 7, this code works fine on Win7, but I have to also work on Win XP, because this is what some clients use)

So my conclusion is that QtSql doesn't work on XP.
Reply
#5
make sure you are using a version of pip that matches your version of python.
each python version has it's own copy of pip. They are in the Scripts directory directly
under the Python root (for example on Windows with Python 3.4 installed in C:\Python34,
pip would be installed in C:/Python34/Scripts/pip.exe
If your path is pointing to another Python version and you don't qualify which pip to use,
it will default to the version that is in the path.
So if you want to assure (on windows) that you're installing for Python 3.4, You can call C:/Python34/Scripts/pip to be sure that you install the proper package.
Reply


Forum Jump:

User Panel Messages

Announcements
Announcement #1 8/1/2020
Announcement #2 8/2/2020
Announcement #3 8/6/2020