16

What is the recommended way of setting up PySide for development in Ubuntu?

  1. sudo apt-get install python3-pyside?
  2. sudo pip install pyside?
  3. sudo easy_install pyside?
Tshilidzi Mudau
  • 7,373
  • 6
  • 36
  • 49
pkaramol
  • 16,451
  • 43
  • 149
  • 324

5 Answers5

9

For all Python packages at this point I prefer to use pip, and not even the ubuntu-managed pip but a custom install. It is better not to mix the two, i.e. if you already have packages installed using the python3-pip Ubuntu package, continue using that.

To install custom pip for a single user, you can first set up the latest version of pip as described here:

https://pip.pypa.io/en/stable/installing/

That is, in short:

curl https://bootstrap.pypa.io/get-pip.py -o get-pip.py

python3 ./get-pip.py

To install PySide with the custom pip use:

pip install --user PySide2

To install PySide with the pip from an Ubuntu-managed apt package (thanks @Suzanne Dupéron for the update on that):

sudo apt install python3-pip && pip3 install PySide2

Currently**, if you have Qt 5.x set as default on your Ubuntu, you may find that

sudo apt-get install python3-pyside

(or python-pyside if you still for some reason want the python 2.7 version) is the only way (without having to revert to Qt 4.x).

The other two ways would return errors of the sort: "Qt QTCORE library not found."

**check the original post date.PySide page on python.org read/reads "PySide requires Python 2.6 or later and Qt 4.6 or better. Qt 5.x is currently not supported."

[EDIT] Thanks to @JBentley for the update: PySide now supports Qt5.

Greg Kramida
  • 4,064
  • 5
  • 30
  • 46
5

All your options will work. It depends what you are trying to achieve with it and how portable it should be. What usually "just" works without problems is to create a virtualenv first:

apt-get -f install python-virtualenv
virtualenv ~/mypython2.7

With that you can simply use easy_install as recommended to install PySide in your local virtual environment:

~/mypython2.7/bin/easy_install PySide

If you want to build PySide, follow the extensive instructions on their github page

romanofski
  • 1,122
  • 1
  • 12
  • 18
  • I think this is the best answer (working in a virtualenv) but I would choose `pip install` over `easy_install`. – pkaramol Mar 01 '16 at 14:57
5

sudo apt-get install python3-pyside is probably the easiest way to install Pyside in Ubuntu.

Tshilidzi Mudau
  • 7,373
  • 6
  • 36
  • 49
0

For development I would not install any development packages to system python - You should use virtualenv. Also if you want to save time, first create the distribution egg via "easy_install bdist_egg". Then you can install the egg to your virtualenv (or system python if you prefer) without recompiling everything. Complete instuctions on how to install dependencies, getting pyside source, building and installing are here

rlacko
  • 571
  • 3
  • 11
0

Build from source


Why?
  1. will be compiled on your platform which is always better.
  2. you will be able to utilize the shiboken_generator later.
  3. you will have the latest updates and bug-fixes, you wont need to wait for releases.

How?
  1. clone this repo inside your project
  2. download qt online installer from qt site and install what you need.
  3. change the qtpaths from the script to your path, should be something like the path in the script.
  4. run the script with your venv running: source install_pyside6.sh.
ניר
  • 1,204
  • 1
  • 8
  • 28