9

http://www.riverbankcomputing.com/software/pyqt/download

I tried many solutions on internet including

brew install qt
brew install sip
brew install pyqt

to successfully install it on osx. I am using PyCharm IDE to python development and want to install it for python 3.

I just cannot download pyqt4 libraries to mac, is there some specific steps i need to follow? Easy way? Hard way? anything...

Sorry, I am new to mac world.

Noorsimar
  • 120
  • 1
  • 2
  • 8

3 Answers3

19

You can install it with homebrew using the --with-python3 flag:

unset PYTHONPATH
brew install sip --with-python3
brew install pyqt --with-python3

And relink the site packages if necessary.

shrx
  • 699
  • 2
  • 8
  • 25
6

The easiest way I've found is to use MacPorts. Once installed, simply run

sudo port install py34-pyqt4

and it will do the rest - install Python 3.4, pyqt4, and all the dependencies. You'll need to configure PyCharm to use the MacPorts version of Python (found in /opt/local/bin), but after that you should be all set. There are many modules available through MacPorts, and for those that aren't you can always install py34-pip.

MattDMo
  • 100,794
  • 21
  • 241
  • 231
  • 1
    I did it but when i try to import it it says: `from PyQt4.QtCore import * ImportError: No module named 'PyQt4'` – Noorsimar Sep 25 '14 at 10:57
  • @Python are you sure you set up PyCharm correctly? The Python executable should be `/opt/local/bin/python3` (assuming you installed in the default location), and `site-packages` should be in `/opt/local/Library/Frameworks/Python.framework/Versions/3.4/lib/python3.4/site-packages` (I'm going from memory here, you'll have to verify the actual path). Check in the `site-packages` folder for a `PyQt4` folder. Also, run `/opt/local/bin/python3` from the command line and try to import PyQt4 that way, just to verify that the installation worked. – MattDMo Sep 25 '14 at 15:11
  • I edited Interpreter location to /opt/local/bin/python3.4 and it worked... but as soon as I opened new project... with same interpreter it gave same error 'no module found' dont know why.. although THANKSSSSS for ur help it worked finally to some extend...... – Noorsimar Sep 25 '14 at 16:13
  • @Python glad I could help. Good luck figuring out PyCharm! I'm a Sublime Text user myself, and while it lacks some of the features of a full-fledged IDE, I've customized it with several plugins for Python coding, and I really like it. – MattDMo Sep 25 '14 at 16:53
3

I know this is from a year ago but this may help someone...

Note: This is for PyQT5 and Python 3. It is an alternative to using homebrew.

Background

If you installed Python 3.x, it installs in a separate directory (leaving your Mac version alone). After adding the new directories to your path, most people can just use python3.5 (or whatever version) to access it without having to change over python alias.

Also note that Python comes with pip right out of the box...

Read more on Python 3 for Mac here.

Answer the question already

Now, all that said, you can simply use the following to install via pip:

sudo python3.5 -m pip install PyQt5

You'll likely have to use sudo. Output should look like:

Collecting PyQt5
  Downloading PyQt5-5.7-cp35-cp35m-macosx_10_6_intel.whl (79.4MB)
    100% |████████████████████████████████| 79.4MB 18kB/s 
Collecting sip (from PyQt5)
  Downloading sip-4.18.1-cp35-cp35m-macosx_10_6_intel.whl (46kB)
    100% |████████████████████████████████| 51kB 9.8MB/s 
Installing collected packages: sip, PyQt5
Successfully installed PyQt5-5.7 sip-4.18.1

Don't forget to use the -m option. It allows for library modules to be run as scripts. From the --help entry:

-m mod : run library module as a script (terminates option list)

Note: Older versions of PyQT cannot be installed via pip.

Geoff
  • 3,534
  • 5
  • 30
  • 33