Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Import Error: Symbol not found: _futimens with PyQT5 in macOS Sierra 10.12.6

So, I'm trying to run a basic code:

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_())

And this error keeps popping up:

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

I'm working on Python 3.8, and I installed PyQT5 with 'pip3 install pyqt5'. I tried with homebrew but it doesn't work because I have a super old version of macOS. So far, I've only worked with SQLite Studio at best, with no issues. (So, yeah, super beginner here). Any solutions?

like image 799
DedUV Avatar asked Feb 19 '20 14:02

DedUV


2 Answers

I had a similar issue with pyqt today, i think that installing a previous version of pyqt maybe will help in your case:

First, starts with your code in a .py file (like demo.py). Then, run this commands to create a virtual environment and install pyqt version 5.13.0:

python3 -m venv myenv
. myenv/bin/activate
pip install PyQt5==5.13.0
python demo.py

enter image description here

like image 100
hugoruscitti Avatar answered Nov 15 '22 00:11

hugoruscitti


The same problem occurred on MacOS 10.12.6 after I installed PyQt5-5.15.0, uninstall this version and downgrade to PyQt5-5.13.0, it works fine!

# on MacOS 10.12.6:
#
# this will install PyQt5-5.15.0 by default 
pip install PyQt5

#!!! not work !!!
# ImportError: PyQt5/QtGui.abi3.so, 2): Symbol not found: _futimens

# uninstall it
pip uninstall PyQt5

pip install PyQt5==5.13.0

# Works perfect now ;-)
like image 25
Randy Avatar answered Nov 15 '22 00:11

Randy