Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

How can i run pyqt5 on my mac with M1chip

now. when i run it. the error conmes ImportError: dlopen(/Users/v/Library/Python/3.8/lib/python/site-packages/PyQt5/QtWidgets.abi3.so, 2): no suitable image found. Did find: /Users/v/Library/Python/3.8/lib/python/site-packages/PyQt5/QtWidgets.abi3.so: mach-o, but wrong architecture /Users/v/Library/Python/3.8/lib/python/site-packages/PyQt5/QtWidgets.abi3.so: mach-o, but wrong architecture

like image 831
vihanchou Avatar asked Jan 26 '21 12:01

vihanchou


People also ask

Is PyQt6 better than PyQt5?

As we've discovered, there are no major differences between PyQt5 and PyQt6. The changes that are there can be easily worked around. If you are new to Python GUI programming with Qt you may find it easier to start with PyQt5 still, but for any new project I'd suggest starting with PyQt6.


2 Answers

After hours of trial and error, I was finally able to solve this. My successful configuration is:

  1. Open terminal with Rosetta 2 (https://dev.to/courier/tips-and-tricks-to-setup-your-apple-m1-for-development-547g)
  2. Use non-homebrew python (mine was in /usr/bin/python3) to create virtual environment
/usr/bin/python3 -m venv env
source env/bin/activate
  1. Upgrade pip
pip install --upgrade pip
  1. Install PyQt5
pip install PyQt5
like image 73
executeinstaller Avatar answered Oct 02 '22 11:10

executeinstaller


I needed PyQt5 as a dependency for a Python library and this worked for me. See original post here.

brew install pyqt5
echo 'export PATH="/opt/homebrew/opt/qt@5/bin:$PATH"' >> ~/.zshrc
echo 'export PATH="/opt/homebrew/opt/pyqt@5/5.15.4_1/bin:$PATH"' >> ~/.zshrc
source ~/.zshrc
like image 38
ejames Avatar answered Oct 02 '22 10:10

ejames