导入错误:未找到符号:macOS Sierra 10.12.6 中使用 PyQT5 _futimens

Ded*_*dUV 5 python importerror symbol-not-found pyqt5 macos-sierra

所以,我正在尝试运行基本代码:

from PyQt5.QtWidgets import QMainWindow, QPushButton, QApplication
import sys

class Example(QMainWindow):
    def __init__(self):
        super().__init__()
        btn = QPushButton("Hello World!", self)
        btn.move(50,75)
        self.setGeometry(100, 100, 200,150)
        self.setWindowTitle('PyQt Window')
        self.show()

if __name__ == '__main__':
    app = QApplication(sys.argv)
    ex = Example()
    sys.exit(app.exec_())
Run Code Online (Sandbox Code Playgroud)

并且不断出现这个错误:

ImportError: dlopen(/Library/Frameworks/Python.framework/Versions/3.8/lib/python3.8/site-packages/PyQt5/QtWidgets.abi3.so, 2): Symbol not found: _futimens
  Referenced from: /Library/Frameworks/Python.framework/Versions/3.8/lib/python3.8/site-packages/PyQt5/Qt/lib/QtCore.framework/Versions/5/QtCore (which was built for Mac OS X 10.13)
  Expected in: /usr/lib/libSystem.B.dylib
 in /Library/Frameworks/Python.framework/Versions/3.8/lib/python3.8/site-packages/PyQt5/Qt/lib/QtCore.framework/Versions/5/QtCore
Run Code Online (Sandbox Code Playgroud)

我正在使用 Python 3.8,并使用“pip3 install pyqt5”安装了 PyQT5。我尝试使用自制软件,但它不起作用,因为我有一个超级旧版本的 macOS。到目前为止,我最多只使用过 SQLite Studio,没有出现任何问题。(所以,是的,这里是超级初学者)。有什么解决办法吗?

hug*_*tti 4

我今天在 pyqt 上遇到了类似的问题,我认为安装以前版本的 pyqt 可能会对您的情况有所帮助:

首先,从 .py 文件(如 demo.py)中的代码开始。然后,运行以下命令创建虚拟环境并安装 pyqt 版本 5.13.0:

python3 -m venv myenv
. myenv/bin/activate
pip install PyQt5==5.13.0
python demo.py
Run Code Online (Sandbox Code Playgroud)

在此输入图像描述