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)?

1
  • 2
    The line apt-get add-apt-repository -y ppa:thopiekar/pyside-git should read add-apt-repository -y ppa:thopiekar/pyside-git on Ubuntu 16.04. Sep 14 '17 at 14:07
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
12
  • Thanks. Any idea on how to fix the following when you execute 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 I think it's because the pyside2uic Python module isn't installed.
    – fredrik
    Sep 18 '16 at 10:01
  • That is odd. The pyside2-tools package does have driver.py, so the module exists.
    – edwinksl
    Sep 18 '16 at 10:10
  • Also, I noticed in your post you tried to install python-pyside2 but I don't think that package exists in the Ubuntu repos nor in the PPA you are using. I think you meant to install pyside2, which is provided by the PPA. Maybe this is related to the problem you have; I am not sure.
    – edwinksl
    Sep 18 '16 at 10:11
  • I'm using this to differentiate between python-pyside2 and python3-pyside2 and it seems to work well eventhough I see the package is called pyside2 in the PPA. However, nothing besides the PySide2 module exists in my /usr/lib/python2.7/dist-packages. If I attempt apt-get install pyside2 I get Unable to locate package pyside2. Hmmm... I really wonder what happened to the pyside2uic package.
    – fredrik
    Sep 18 '16 at 10:22
  • I think I found what's causing issues for me: pastebin.com/UyCKiPRM
    – fredrik
    Sep 18 '16 at 10:28
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 .

1
  • I get the following error, running pyside2-uic with python3 on Ubuntu 16.04: ImportError: No module named 'PySide2' Also it seems pyside2 is not provided for python3 with this ppa.
    – Chris
    Jun 20 '19 at 7:54

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.