Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

How to get PyQt4 working with PyCharm

So I'm trying to get a program that uses PyQt4 to work in PyCharm on my Mac, but whenever it tries to run, it says

INFO: Could not import backend "PyQt4":

No module named PyQt4

Trying to import PyQt4 using PyCharm's Package Manager generates this error:

Executed Command:

pip install PyQt4

Error Occurred:

0:428: execution error: The directory '/Users/pkillam/Library/Caches/pip/http' or its parent directory is not owned by the current user and the cache has been disabled. Please check the permissions and owner of that directory. If executing pip with sudo, you may want sudo's -H flag.

Proposed Solution:

Try to run this command from the system terminal. Make sure that you use the correct version of 'pip' installed for your Python interpreter located at '/System/Library/Frameworks/Python.framework/Versions/2.7/bin/python2.7'.

This only happens to certain packages which pip doesn't like, particularly those which use configure.py instead of setup.py as explained here.

Attempting to run the command from the console generates this error:

$ pip install PyQt4

Collecting PyQt4 Could not find a version that satisfies the requirement PyQt4 (from versions: ) No matching distribution found for PyQt4

$

Now, installing the package using homebrew claims to be successful, but I still get the initial error that PyQt could not be imported after homebrew installs it.. somewhere.

I've been running around in circles with this for the past day, any ideas?

like image 711
NGXII Avatar asked Jul 29 '15 21:07

NGXII


People also ask

How to use QT designer with PyCharm?

Go to File > Settings > tools > PyCharm External Tools , and include the following information to add them to your project. Later, you will be able to right click a . ui file, and select Qt Designer , pyside6-uic , or any tool that you configured this way.

Is PyQt4 compatible with Python 3?

PyQt4 is a comprehensive set of Python bindings for Digia's Qt cross platform GUI toolkit. PyQt4 supports Python v2 and v3.

Does PyCharm support PyQt5?

Install designerOnce qt5-designer is installed, you can configure it in PyCharm.


2 Answers

You can try to install PyQt4 by downloading it from the official Website. Remember to download PyQt version same as your python version. If you have python 2.7 32bit then download PyQt4 32bit even if your computer is 64 bit.
Similarly, if you have Python 3.x 64bit then you need to download PyQt4 64bit.
You can check your Python version from the default Python 'IDLE'. It should be similar to this.
Python 3.4.3 (v3.4.3:9b73f1c3e601, Feb 24 2015, 22:43:06) [MSC v.1600 32 bit (Intel)] on win32

like image 85
Digvijayad Avatar answered Sep 22 '22 02:09

Digvijayad


You could try PyQtX. It's not perfectly up-to-date, but maybe a quick solutions in your case.

like image 25
sonovice Avatar answered Sep 23 '22 02:09

sonovice