Before you start the PySide2 tutorial you will need to have a working installation of PySide2 on your system. If you don't have either set up yet, the following steps will guide you through how to install PySide2 on macOS.
This guide is also available for Linux and Windows.
Install PySide2 on macOS using pip
If you already have a working installation of Python 3 on macOS, you can go ahead and install PySide2 as for any other Python package, using the following --
pip3 install pyside2
If you don't have an installation of Python 3, you will need to install one first. You can download macOS installers for Python 3 from the Python homepage. Once installed, you should be able to use the pip3 install command above to install PySide2.
Install PySide2 on macOS using Homebrew
Another alternative is to use Homebrew. Homebrew is a package manager for command-line software on macOS. Homebrew has both Python 3 and PySide2 available in their repositories, making it a convenient way to set up your Python GUI development environment on Mac.
Homebrew -- the missing package manager for macOS
To install Homebrew run the following from the command line --
ruby -e "$(curl -fsSL https://raw.githubusercontent.com/Homebrew/install/master/install)"
This is also available to copy and paste from the Homebrew homepage.
Install Python 3 with Homebrew
Once Homebrew is installed you can then install Python 3 with --
brew install python3
Install PySide2 with pip or Homebrew
With Python 3 installed, you can then install PySide2 as normal, using pip3 install pyside2, or alternatively choose to install it using Homebrew with --
brew install pyside2
Verify your PySide2 installation
After installing PySide2, you can verify the installation was successful by running the following command in your terminal --
python3 -c "import PySide2; print(PySide2.__version__)"
If PySide2 is installed correctly, this will print the version number. You're now ready to start building Python GUI applications with PySide2 on macOS. Head over to the PySide2 tutorial to get started with your first app.
PyQt/PySide Development Services — Stuck in development hell? I'll help you get your project focused, finished and released. Benefit from years of practical experience releasing software with Python.