【问题标题】:Python3 can't find and import PyQt5Python3 找不到并导入 PyQt5
【发布时间】:2015-05-09 22:34:59
【问题描述】:

我用 brew 安装了 PyQt5,它似乎正确地结束了安装过程。

$ brew install pyqt5 --with-python3

问题是我无法导入:

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'

我从哪里开始寻找它为什么不起作用?我认为它会使用我使用的 brew 命令将其自动添加到 Python 中。

【问题讨论】:

    标签: macos python-3.x pyqt5


    【解决方案1】:

    一种可能的解决方案是使用以下命令查找安装路径:

    brew info pyqt5
    

    然后将其添加到您的 Python 路径中,您可以在此处找到解决方案:

    Permanently add a directory to PYTHONPATH

    你的问题也和这个类似

    HomeBrew Mac change Python Path

    【讨论】:

    • 太棒了,成功了 :) 进行了一些研究,但由于 brew 路径不是实际包含 __init__ 的路径,那是两个更下方的目录。
    • 当我意识到您发布的第二个链接更好,因为它会自动运行并开始尝试时,我正要这样做:)
    猜你喜欢
    • 2015-08-17
    • 1970-01-01
    • 2019-03-20
    • 2023-03-16
    • 2021-05-04
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 2016-01-31
    相关资源
    最近更新 更多