2.5.2.2 Installing PyQt6

2.5.2.2 Installing PyQt6

In contrast to tkinter, PyQt6 is not part of the Python standard library and may or may not be available to install through Pro's Package Manager. We can though, use the Package Manager to clone the default environment and use the Python Command Window to install the packages we need.

Create another clone of the default environment, giving it a name such as arcgispro-py3-pyqt and activate it. You can check the Installed Packages list to see if pyqt is installed at this time, but more likely it will not be installed. If it is not installed, go to Add Packages and type "pyqt".  It may not be listed as a package to add in this curated list by esri's included version of conda so we will need to use the Python Command prompt to install the package. There are two quick ways to start a command window in your py3-pyqt conda environment:

In your Windows start menu:

Windows start menu highlighted

search for "Python Command Prompt" and it should result in a "Best match". After opening, be sure to verify that it opened the environment you want to work in (details below).

Python Command Prompt search and highlighted

Or, you can navigate to it by clicking the "All" to switch to the application list view.

All drop down highlighted

Scroll down the list and expand the ArcGIS folder to list all ArcGIS applications installed.

ArcGIS program folder highlighted

Scroll down and open the Python Command Prompt.

Python Command Prompt highlighted

This is a shortcut to open a command window in the activated python environment. Once opened, you should see the environment name in parentheses followed by the full path to the python environment.

Conda env name highlighted

When you change your activated environment in Pro's Package Manager, this shortcut will also be updated to point to that activated environment.

Type 'pip install PyQt6' without the quotes and hit enter.

pip install PyQt6 PyQt6-WebEngine PyQt6-tools

If there are no errors, and is done installing, type 'pip install PyQt6-WebEngine' and hit enter. Again, if there are no errors, and it completes installing, type 'pip install PyQt6-tools and hit enter. Proceed through the prompts and if this does not install, please let your instructor know. When it completes, you probably now have version 6.8.0 or later of pyqt installed. Next, try to run the test code on the next page. Let your instructor know if you are not able to run the application.

PySide6 Install (only if PyQt6 fails to install)

In the event that any of the PyQt6 packages do NOT install, we will need to roll back any packages that were installed and install PySide6. With the command window, run the command pip uninstall pyqt6, changing the package name to any pyqt6 packages that were installed. You can check by entering conda list to see the list of packages installed.

PySide6 is fully compiled, so the PyQt6-tools and PyQt6-WebEngine is included within pyside6 so we only need to run pip install pyside6.

Once completed, the pyside6-uic.exe used for translated .ui files is found in the Scripts folder in your python environment path  C:\...\envs\arcgispro-py3-pyqt\Scripts\pyside6-uic.exe.

Take note that the command line syntax for pyside6-uic.exe is slightly different than PyQt6:


"C:\...\envs\arcgispro-py3-pyqt\scripts\pyside6-uic.exe" path_to_your_file.ui -o desired_output_file.py

The QtDesigner.exe that we will use is located in the PySide6 folder in site-packages: C:\...\envs\arcgispro-py3-pyqt\Lib\site-packages\PySide6\designer.exe. Navigate to this folder and make it a shortcut on your desktop so you can get to it easily.

If you have any problems with PySide6 installing, please let your instructor know. If it installed, you can test it by running the example on the next page. Let your instructor know if you are not able to run the application. Changing to PySide6 is mostly a one-for-one change, meaning the you can change PyQt6 to PySide6 in the lesson's content and code examples (with some exceptions that can be fixed by reviewing the documentation) and they will work.

mrs110