3

You can install PySide2 like so:

apt-get update
apt-get install -y software-properties-common
add-apt-repository -y ppa:thopiekar/pyside-git
apt-get update
apt-get install -y python
apt-get install -y python-dev
apt-get install -y python-pyside2

But how do you install the pyside2-uic executable along with its dependencies (the pyside2uic Python module)?

fredrik
  • 283

2 Answers2

3

The pyside2-uic file is provided by the pyside2-tools package from the PPA you gave. Therefore, you install pyside2-tools using:

sudo apt-get install pyside2-tools
edwinksl
  • 24,109
1

tl;dr

  • Install pyside2-tools.

    sudo apt-get install pyside2-tools
    
  • Force pyside2-uic to run as a Python 3 script.

    • Manually edit /usr/bin/pyside2-uic as the superuser with your favourite religious-war text editor – in my case, vim.

      sudo vim /usr/bin/pyside2-uic
      
    • Edit the first line to read:

      #! /usr/bin/python3
      

Voila!

wut?

Installing pyside2-tools without manually editing /usr/bin/pyside2-uic as suggested by edwinksl's prior answer results in a fatal exception on running pyside2-uic:

$ pyside2-uic
Traceback (most recent call last):
  File "/usr/bin/pyside2-uic", line 28, in <module>
    from pyside2uic.driver import Driver
ImportError: No module named pyside2uic.driver

The reason why appears to be that the PySide2 PPA installs the pyside2uic package for Python 3 but not Python 2.

Even if this PPA did correctly install the pyside2uic package for both, however, the resulting pyside2-uic script would still only be usable by Python 2 users. Python 3 users would be hung out to dry. Since Python 2 is nearing its end-of-life, that would be bad.

Ultimately, the only viable long-term solution is for this PPA to provide two different packages:

  • python3-pyside-tools, providing Python 3-specific PySide 2 utilities with Python 3-specific filenames (e.g., /usr/bin/pyside2-uic-py3).
  • python2-pyside-tools, providing Python 2-specific PySide 2 utilities with Python 2-specific filenames (e.g., /usr/bin/pyside2-uic-py2).

Python 2 and 3 are two distinct languages. You gotta keep 'em separated.

Until that wondrous day, the above solution will have to do. Thanks for all the PySide 2 packaging, Thomas Karl Pietrowski .