[] Installing Python packages via pip fails

asked 2019-03-25 14:51:21 +0300

NobodyInPerson gravatar image

updated 2019-03-25 16:34:49 +0300

First thing: Thank you very much for updating Python from 3.4 to 3.7, this is huge!

There is a small issue with pip however. If you attempt to install anything via pip, the following happens:

> /usr/bin/pip3 install --user -U pip
... a lot of Traceback ...
subprocess.CalledProcessError: Command '('lsb_release', '-a')' returned non-zero exit status 3.

Indeed, running lsb_release -a fails with error code 3:

> lsb_release -a
LSB Version:    :core-3.1-arm:core-3.1-noarch:core-3.2-arm:core-3.2-noarch:core-4.0-arm:core-4.0-noarch:desktop-3.1-arm:desktop-3.1-noarch:desktop-3.2-arm:desktop-3.2-noarch:desktop-4.0-arm:desktop-4.0-noarch
Distributor ID: n/a
Description:    (none)
Release:        n/a
Codename:       n/a
> echo $?

However, pip can be set up to not use lsb_release to detect the linux distribution. As a quick fix, line 573 in file /usr/lib/python3.7/site-packages/pip/_vendor/distro.py can be changed to


for obvious reasons. Now, pip works agains as expected.

If you get annoyed by the ”pip is outdated” warning and decide to update it via python3 -m pip install --user -U pip, keep in mind that this installs a new copy of pip under ~/.local/lib/python3.7 and you will have to apply the above fix there as well.

Maybe it's possible to change this line permanently in the python3-base package? Fixing lsb_release itself seems to be a problem as explained in this answer.



edit retag flag offensive close delete


Is pip now included by default? Just checked and the manually installed one in python3.4 dir is 19.0.3, it does have include_lsb=True, and it didn't seem to throw any errors

szopin ( 2019-03-26 12:39:40 +0300 )edit

Yes, pip is included by default (see output of rpm -ql python3-base | grep pip). I don't have a SailfishOS device with 3.0.1 Sipoonkorpi at hand, but my guess is that for some reason, lsb_release behaves differently there so that pip doesn't fail.

NobodyInPerson ( 2019-03-26 13:40:33 +0300 )edit

I still have leftover python3.4 directory with the manually installed pip (pretty sure it wasn't installed by default then as had to look for it), was just wondering if pip got included by the system update somehow and downgraded in the process, as used to work fine. Worst part is not sure how to uninstall old packages I installed using it as now both pip and pip3 only find 2, I guess will just manually delete the 3.4 dir, but will most likely have some leftovers eating into the limited sys partition. At least we got pip now officially yay!

szopin ( 2019-03-26 13:50:51 +0300 )edit

As a tip for problems with the pip and pip3 executable scripts: Don't use them. Use python3 -m pip instead. It's far more robust.

NobodyInPerson ( 2019-03-26 13:53:40 +0300 )edit

I only used it to install streamlinks as it seems the only way to watch streams on sailfish, so can hopefully track down all the components it installed, but had no problems with using just pip, but thanks for the tip (btw the parameters you listed '--user -U pip' will make it install in local dirs instead of global right? if all libs/executables end up in same sub dirs this will help me track all the mess)

szopin ( 2019-03-26 13:56:58 +0300 )edit