Installing PyQt4 on Mac OSx Mavericks?
Solution 1
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
.
Solution 2
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.
Solution 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.
Python
Updated on July 23, 2022Comments
-
Python almost 2 years
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.
-
Python over 9 yearsI did it but when i try to import it it says:
from PyQt4.QtCore import * ImportError: No module named 'PyQt4'
-
MattDMo over 9 years@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), andsite-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 thesite-packages
folder for aPyQt4
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. -
Python over 9 yearsI 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......
-
MattDMo over 9 years@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.
-
Md. Minhazul Haque over 8 years
brew uninstall sip
andbrew install sip --with-python3
solved the problem. -
jjrr almost 2 yearsmaybe this needs an update, given that
--with-python3
is not a valid option anymore...