Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Qt5 breaks Matplotlib ? #1249

Closed
zimoun opened this issue Nov 21, 2016 · 11 comments
Closed

Qt5 breaks Matplotlib ? #1249

zimoun opened this issue Nov 21, 2016 · 11 comments

Comments

@zimoun
Copy link

zimoun commented Nov 21, 2016

Dear,

I am running under Debian testing and Python 3.

The environment is created by: conda create -n arf python=3.
And, the simple test is: python simple.py with the small script simple.py, i.e.,

import matplotlib.pyplot as plt
x = [1, 2, 3]
y = [2, 4, 6]
plt.plot(x, y)

If conda install matplotlib=1.5.1 then it is ok.
However, if conda install matplotlib=1.5.3 then it crashes with the message:

$ python simple.py
This application failed to start because it could not find or load the Qt platform plugin "xcb"
in "".

Available platform plugins are: minimal, offscreen, xcb.

Reinstalling the application may fix this problem.
Aborted

I did not dive too much into the issue. It appears to me that the problem comes from Qt5.
Matplotlib 1.5.1 is built against the version Qt 4.8.7-4 and pyqt 4.11.4 ; and the version 1.5.3 against the version 5.6.0.

Is it system side ? If yes, I have no clue why ?
Or is it conda side ?
Or maybe the upgrade Qt4->Qt5 is not fully ready ? If yes, I could provide more elements to try to fix the dependency issue.

Cheers

@ccordoba12
Copy link

Is it system side ? If yes, I have no clue why ?
Or is it conda side ?

This only affects conda packages.


Question: Do you have libselinux installed in your system?

@zimoun
Copy link
Author

zimoun commented Nov 22, 2016

Yes, I have libselinux1 2.5-3 packaged by Debian.
From what I know, it is installed by default.

Where does the issue come from ?
Because, the link between both does not appear to me fully clear.

@mingwandroid
Copy link

Please show the output from conda info and conda list --show-channel-urls

@zimoun
Copy link
Author

zimoun commented Nov 22, 2016

$ conda info
Current conda install:

               platform : linux-64
          conda version : 4.2.12
       conda is private : False
      conda-env version : 4.2.12
    conda-build version : 1.21.11+0.g5b44ab3.dirty
         python version : 3.5.2.final.0
       requests version : 2.9.1
       root environment : /home/simon/miniconda  (writable)
    default environment : /home/simon/miniconda/envs/arf
       envs directories : /home/simon/miniconda/envs
          package cache : /home/simon/miniconda/pkgs
           channel URLs : https://repo.continuum.io/pkgs/free/linux-64
                          https://repo.continuum.io/pkgs/free/noarch
                          https://repo.continuum.io/pkgs/pro/linux-64
                          https://repo.continuum.io/pkgs/pro/noarch
            config file : None
           offline mode : False
$ conda list --show-channel-urls
# packages in environment at /home/simon/miniconda/envs/arf:
#
cairo                     1.12.18                       6    defaults
cycler                    0.10.0                   py35_0    defaults
dbus                      1.10.10                       0    defaults
expat                     2.1.0                         0    defaults
fontconfig                2.11.1                        6    defaults
freetype                  2.5.5                         1    defaults
glib                      2.43.0                        1    defaults
gst-plugins-base          1.8.0                         0    defaults
gstreamer                 1.8.0                         0    defaults
harfbuzz                  0.9.39                        1    defaults
icu                       54.1                          0    defaults
jpeg                      8d                            2    defaults
libffi                    3.2.1                         0    defaults
libgcc                    5.2.0                         0    defaults
libpng                    1.6.22                        0    defaults
libxcb                    1.12                          1    defaults
libxml2                   2.9.2                         0    defaults
matplotlib                1.5.3               np111py35_1    defaults
mkl                       11.3.3                        0    defaults
numpy                     1.11.2                   py35_0    defaults
openssl                   1.0.2j                        0    defaults
pango                     1.39.0                        1    defaults
pip                       9.0.1                    py35_0    defaults
pixman                    0.32.6                        0    defaults
pyparsing                 2.1.4                    py35_0    defaults
pyqt                      5.6.0                    py35_0    defaults
python                    3.5.2                         0    defaults
python-dateutil           2.6.0                    py35_0    defaults
pytz                      2016.7                   py35_0    defaults
qt                        5.6.0                         1    defaults
readline                  6.2                           2    defaults
setuptools                27.2.0                   py35_0    defaults
sip                       4.18                     py35_0    defaults
six                       1.10.0                   py35_0    defaults
sqlite                    3.13.0                        0    defaults
tk                        8.5.18                        0    defaults
wheel                     0.29.0                   py35_0    defaults
xz                        5.2.2                         0    defaults
zlib                      1.2.8                         3    defaults

@mingwandroid
Copy link

I cannot reproduce this on the latest ArchLinux. Can you install strace and show the output from strace -f python simple.py please?

Can you show the output of env too?

@zimoun
Copy link
Author

zimoun commented Nov 22, 2016

Let the outputs attached:
env.txt
strace.txt

Let me know if you need more.

Cheers

@mingwandroid
Copy link

Thanks. Looking at your strace.txt, we see:

open("/usr/lib/x86_64-linux-gnu/libQt5DBus.so.5", O_RDONLY|O_CLOEXEC) = 4

.. so this is not conda's libQt5DBus.so.5. The reason it has found this is because your env. contains LD_LIBRARY_PATH=/home/simon/local/lib:/lib/x86_64-linux-gnu:/usr/lib/x86_64-linux-gnu.

I am not sure why you have LD_LIBRARY_PATH set, but this is the likely cause of the issue you are seeing. Many people, myself included consider LD_LIBRARY_PATH harmful, and I would encourage figuring out why it is set and seeing if you can remove that. A potential workaround would be to add your conda root's lib dir to the front of LD_LIBRARY_PATH but that will just cause trouble for other software (and potentially your system/distribution software), so if you are going to try that, please do not set it globally (i.e. do not set it in a login script).

The best approach is to try not to set that variable except in the terminal session where you are trying out some locally built versions of some libraries (or whatever the reason was that you have it set).

For more information on the harm please see https://gms.tf/ld_library_path-considered-harmful.html:

The page LD_LIBRARY_PATH Is Not The Answer references David Barr's article and calls globally setting the LD_LIBRARY_PATH a 'complete hack'.

.. and https://wiki.debian.org/RpathIssue

LD_LIBRARY_PATH can't be used because it has its own problems: it'll be inherited by all processes generated by the parent and is therefore also discouraged for distribution-wide use for its possible side-effects.

@zimoun
Copy link
Author

zimoun commented Nov 22, 2016

Thank you.
And thank you for the clear explanations.

Yes, if I unset LD_LIBRARY_PATH, then it works.

I need to think how to re-configure.
If I remember well, I did that because some programs did not find the correct path, and I was annoyed to set/unset when compiling them. So I set it in my .bashrc. Anyway.

Thank you again for the fix and the explanations.

@jdhao
Copy link

jdhao commented Feb 10, 2017

I have also met this problem, following @mingwandroid's suggestion, I removed the /usr/lib64 from the LD_LIBRARY_PATH and the problem was solved.
But there is another annoying problem, every time I execute a python script in the shell using python simple.py, an error/warning message occured:

failed to get the current screen resources
QXcbConnection: XCB error: 170 (Unknown), sequence: 164, resource id: 90, major code: 146 (Unknown), minor code: 20

The simple.py script could be

import matplotlib.pyplot as plt
x = [1, 2, 3]
y = [2, 4, 6]
plt.plot(x, y)
plt.show()

If I comment out plt.show or replace it with plt.savefig('simple.py') the error message becomes solely

failed to get the current screen resources

I have search the web, but found no helpful message about how to solve this issue. I am not familiar with the qt and xcb package, I guess this still has something to do with the qt package and xcb. Is there anyway to fix this problem?

@jdhao
Copy link

jdhao commented Feb 12, 2017

The above failed to get the current screen resources error is due to compatibility issue of Anaconda's matplotlib with qt 5.x. The solution is to use matplotlib 2.0.0 with qt version 4.x. For more information, see
matplotlib/matplotlib#8058

Indeed, the initial comment was wrong. The error is caused by qt5.x, not relevant to matplotlib, since executing the script here (matplotlib/matplotlib#8058 (comment)) also shows the same error message.

@tacaswell
Copy link

I do not believe that Matplotlib is relevant here, this is an issue with qt5 only.

Only commenting here because I think the last comment is wrong, please respond at #1440

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

5 participants