Loading video player…

Installing PyQt

00:00 Installing PyQt. You have several options for installing PyQt on your system or development environment. Most of the time, you should create a Python virtual environment to install PyQt6 in an isolated way.

00:16 On screen, you can see the commands to create a virtual environment and install PyQt6, firstly on Linux and macOS,

00:40 and secondly on Windows.

00:44 In both these cases, you first create a virtual environment using the venv module from the standard library. It’s then activated, and finally, PyQt6 is installed using pip.

00:56 Note that you’ll need Python 3.8 or later for PyQt6 to install.

01:03 It is possible to install PyQt6 directly into your system Python environment, with the command you saw earlier, but without a virtual environment active. While this is a fast way to install PyQt6 and start using it right away, it’s not the recommended approach.

01:19 Generally, you should use a Python virtual environment as seen previously. Several Linux distributions include binary packages for PyQt6 in their repositories.

01:31 If this applies to you, then you can install the library using the distributions package manager on screen. You can see the command you’d need for Ubuntu. Here you’ll install PyQt6 and its dependencies into the base system, so you can use the library in any of your GUI projects.

01:49 Note that root privileges are needed, which you invoke with the sudo command.

02:00 If you’re a macOS user, then you can install PyQt6 using the Homebrew package manager. To do this, open a terminal and enter the command seen on screen.

02:20 After running this, you’ll have PyQt6 installed on your Homebrew Python environment, and it will be ready to use.

02:29 Note that typically the versions installed by package managers may not be the latest version of PyQt6. A pip installation will be better if you want to ensure that you have the latest release.

02:41 Another installation option is to build PyQt from source. This can be a bit complicated, so you may want to avoid it if possible, but if you really do need to build it from source, then check out the library’s documentation recommendations at the links seen on screen.

02:58 So now that you have PyQt6 installed, in the next section of the course, you’ll be creating your first PyQt application.

Become a Member to join the conversation.