4

I am trying to install PyQT4 on Python 2.7.9, I am on Mac OS X, so i tried installing it via Homebrew and Macports, unfortunately non of them seemed to work.

This is what I tried:

brew install python qt pyqt pyside pyside-tools

also tried:

brew install PyQT4

On Macports:

sudo port install py27-pyqt4

No matter what I did, I was getting this error:

>>>> import PyQT4
Traceback (most recent call last):
  File "<stdin>", line 1, in <module>
ImportError: No module named PyQT4

What can be the problem? Do I need to set env path for PyQT?

peterh
  • 11,875
  • 18
  • 85
  • 108
ShellRox
  • 2,532
  • 6
  • 42
  • 90

2 Answers2

7

Found out solution:

I installed PyQtX package, (PyQt binary for Mac OS X) from here.

and then specified PYTHONPATH with this:

export PYTHONPATH=/usr/local/lib/python2.7/site-packages:$PYTHONPATH

After typing in import PyQt4 it worked without any problems. (Case Sensitive)

techraf
  • 64,883
  • 27
  • 193
  • 198
ShellRox
  • 2,532
  • 6
  • 42
  • 90
  • 3
    If you don't want to perform the export, you can do the following prior to importing PyQt4: `import sys; sys.path.append('/usr/local/lib/python2.7/site-packages')` – fredrik Apr 14 '16 at 13:35
  • 4
    On my Mac El Capitan 10.11.6 running the PyQt4 installer reported "Python 2.7 from official python website is not installed." and failed to continue. – Marcel Stör Nov 24 '16 at 19:25
  • @MarcelStör make sure you have installed python 2.7 from it's installer (It would be best way to install python ), but before doing that, delete the old directory: `rm -rif /usr/local/lib/python2.7/` – ShellRox Nov 25 '16 at 07:15
  • 3
    ATM I'm lost among the various Python installation options (Apple, official, MacPorts, Homebrew). Trying to revert to clean-sheet installation. – Marcel Stör Nov 25 '16 at 08:25
  • @MarcelStör i would recommend downloading it's `.pkg` installer from official website. – ShellRox Nov 25 '16 at 09:06
  • Installed Python 2.7. Worked to launch PyQt4 – J A S K I E R Mar 29 '18 at 08:51
  • Started installing PyQt4 ... (may corrupt system. failed.) I don't know how it works for others but it is not a solution at all ._. – J A S K I E R Mar 29 '18 at 08:52
0

This worked out for me: https://robonobodojo.wordpress.com/2017/02/08/installing-pyqt4-on-mac-osx/

What did it was brew install cartr/qt4/pyqt

o_ren
  • 772
  • 1
  • 7
  • 14