Question

Running Ubuntu QQ:

I have a Python project that uses PyQt. In several places I import QtCore and QtGui:

from PyQt4 import QtCore, QtGui

Until now, I have been using python3.2.x (3?)

When I run pylint against such files it reports an error:

"Line 1 E: No name 'QtCore' in module 'PyQt4' 

But the application runs fine anyhow.

Now I installed Python 3.3 (on same path: .. /usr/bin/ ) and configured my project to use python3.3 and python fails:

builtins.ImportError: cannot import name QtCore
File "/myfile.py", line 1, in <module>
from PyQt4 import QtCore

What is going on? With python3.2, pylint reports error, Python has no problem with it, but with python3.3 it fails, with the error pylint reported in python3.2?

Was it helpful?

Solution

The "error" pylint reports on PyQT import is because since PyQT has some C++ or some C in it, pylint cannot easily and automatically introspect the PyQt module and determine if your code correctly imports bits of that 3rd party module.

To solve that, there is an plugin project to pylint called pylint-brains into which one can specify ways of introspecting specific modules (or faking their introspection). It would be nice to have a contribution that would remove the "E" of this pretty common import.

For the ImportError, as discussed in the comments, I believe either you have to re-install PyQt for this version of python or PyQt is not yet compatible with 3.3, or something in your pythonpath is wrong.

Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top