3

I've followed the instructions on:

http://danmarner.com/2014/04/23/Installing-PyQt5-with-Python-3-On-OS-X.html

to first install SIP according to the instructions found at:

http://pyqt.sourceforge.net/Docs/sip4/installation.html

and then PyQt5 by following the instructions found here:

http://pyqt.sourceforge.net/Docs/PyQt5/installation.html

and then brew install qt5

but when I run the first example PyQt-gpl-5.3.2/examples/tutorials/addressbook/part1.py it fails with the following:

Traceback (most recent call last):
  File "examples/tutorials/addressbook/part1.py", line 45, in <module>
    from PyQt5.QtCore import Qt
ImportError: No module named PyQt5.QtCore

I'm running Mavericks 10.9.5 and Python 2.7.5

It doesn't seem like it's installed correctly, or if it is python can't find it. I'm not sure how to proceed so any suggestions are much appreciated!

Liam
  • 1,041
  • 2
  • 17
  • 31
  • Both python and qt5 need to be installed via brew. And brew needs to be in your path. – Nima Dec 05 '14 at 19:31
  • Thanks @Kash, I've install python with homebrew, and it appears to be in my path `/usr/local/bin` but running the example still produces the same error. – Liam Dec 05 '14 at 19:39
  • Can you do: ```from PyQt5.QtWidgets import QtGui, QtCore```? – Nima Dec 05 '14 at 19:48
  • Open IDLE and import PyQt5. If there is no error, then you succesfuly import. Otherwise it's not. That's the way how to check modules are fine – GLHF Dec 05 '14 at 19:51
  • @Kash it fails with `ImportError: No module named PyQt5.QtWidgets` I have a feeling it has something to do with my PATH – Liam Dec 05 '14 at 19:51
  • @qqvc that fails with `ImportError: No module named PyQt5` so python doesn't see PyQt – Liam Dec 05 '14 at 19:52
  • @Liam btw the most important mistake is, if you didnt open the cmd in the SAME path with your PyQt module, then its never going to install correctly. Carefull about that. For example, if PyQt installer is in the desktop, then you have to open cmd on the desktop. If PyQt is in the C:\something\somethingmore then you have to open cmd in the somethingmore.. – GLHF Dec 05 '14 at 19:53

2 Answers2

1

The issue was resolved by adding /usr/local/lib/python2.7/site-packages to PYTHONPATH. Thanks to the comments found here:

https://stackoverflow.com/a/13103438/1729686

and to @Kash and @qqvc for the suggestions!

Community
  • 1
  • 1
Liam
  • 1,041
  • 2
  • 17
  • 31
1

if you used brew, you can add into .bashrc

export PYTHONPATH=$(brew --prefix)/lib/python3.6/site-packages:$PYTHONPATH

(edit python3.6 to your python version).

And next, reload bash and run

echo $PYTHONPATH

if response not null, thats ok

redflasher
  • 677
  • 9
  • 17