Skip to content

Getting going with PyQt5

Peter Corke edited this page Jul 9, 2023 · 3 revisions

PyQt5 is cross-platform GUI toolkit, a set of python bindings for Qt v5.

To run bdedit you must have Qt installed. It is not specified as a dependency for bdsim since the whole aim of bdsim is to do block diagrams with code not diagrams.

For most platforms installing PyQt5 is as simple as

pip install PyQt5

and you test your install by running

python bdsim/bdedit/pyqt5_hello.py

which results in the following popup

Screenshot 2023-07-09 at 12 53 26 pm

There are lots of online resources related to installing and debugging PyQt5, I will ignore GitHub Issues posted on this topic.

PyQt5 on Apple Silicon

PyQt5 is meant to be cross-platform but running on Apple Silicon is not quite so straightforward. This is what worked for me:

brew install qt
brew install pyqt5

which seems to install it into the site-packages folder for all your current python versions.

To use it, you need to set the python path according to the version of Python you want this to work for. For the case of Python 3.9 and using tcsh/csh write:

setenv PYTHONPATH /opt/homebrew/opt/pyqt5/lib/python3.9/site-packages

and for bash write:

export PYTHONPATH=/opt/homebrew/opt/pyqt5/lib/python3.9/site-packages

Test your install by running

python bdsim/bdedit/pyqt5_hello.py

If you have issues check out the relevant online resources. I will ignore GitHub Issues posted on this topic.