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

mightimaus
  • 103
  • 3
fredrik
  • 253
  • 1
  • 2
  • 12
  • 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. – HappyCactus Sep 14 '17 at 14:07

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
  • 23,569
  • 16
  • 74
  • 100
  • 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 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](http://pastebin.com/ygj7qHUP) eventhough [I see the package is called `pyside2` in the PPA](https://launchpad.net/~thopiekar/+archive/ubuntu/pyside-git). 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: http://pastebin.com/UyCKiPRM – fredrik Sep 18 '16 at 10:28
  • Hm, fixing that [clearly installs `pyside2-tools`](http://pastebin.com/rGQ1WEsp) without issues but there's no `pysideuic2` module to be found. Any ideas why? – fredrik Sep 18 '16 at 10:33
  • @fredrik I now see why installing `python2-pyside` works, so what you did for that is correct. As for why there is no `pysideuic2` module, that is very intriguing. It is there is in the [`tar.gz` file](https://launchpad.net/~thopiekar/+archive/ubuntu/pyside-git/+files/pyside2-tools_0.0.0-0~201605121616~rev98~pkg4~ubuntu16.04.1.tar.xz) for `pyside2-tools`. – edwinksl Sep 18 '16 at 10:38
  • Indeed it is. That's odd. – fredrik Sep 18 '16 at 10:40
  • @fredrik Oh, I think I know what happened. It is installed for Python 3, not Python 2. It looks like the `pyside2uic` provided by the PPA is only for Python 3, not Python 2. See if you find anything interesting at `/usr/lib/python3/dist-packages`. – edwinksl Sep 18 '16 at 10:49
  • Well, would you [look at that](http://pastebin.com/xRNguUJQ)! It's in the Python 3 dist-packages. Copying that into `/usr/local/lib/python2.7/dist-packages` made pyside2-uic work! Could you please add this to your answer and I'll mark it as the correct one. – fredrik Sep 18 '16 at 10:52
  • @fredrik Hmm, I am not sure if copying an ostensibly Python 3 package into the `dist-packages` for Python 2.7 is a good idea. Perhaps you can try using `pyside2uic` for a bit before we decide it actually works? :) – edwinksl Sep 18 '16 at 10:56
  • Sure. At least it looks like a pure-Python package. I'll give it a shot. – fredrik Sep 18 '16 at 10:58
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 .

Cecil Curry
  • 540
  • 1
  • 4
  • 6
  • 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 07:54