Python3 can't find and import PyQt5

2019-09-08 18:00发布

问题:

I installed PyQt5 with brew and it appears to end up the install process properly.

$ brew install pyqt5 --with-python3

The problem is that I can't get it to import:

Python 3.4.3 (v3.4.3:9b73f1c3e601, Feb 23 2015, 02:52:03) 
[GCC 4.2.1 (Apple Inc. build 5666) (dot 3)] on darwin
Type "help", "copyright", "credits" or "license" for more information.
>>> import PyQt5
Traceback (most recent call last):
  File "<stdin>", line 1, in <module>
ImportError: No module named 'PyQt5'

Where do I start looking to find out why its not working? I thought it would add it automatically to Python using the brew commmand that I used.

回答1:

A possible solution is to find the installation path using:

brew info pyqt5

and then add it to your Python path, you can find the solution for that here:

Permanently add a directory to PYTHONPATH

Also your question is similar to this one

HomeBrew Mac change Python Path