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

pyplot not working in ipython #80147

Open
btlvr opened this issue Feb 14, 2020 · 13 comments
Open

pyplot not working in ipython #80147

btlvr opened this issue Feb 14, 2020 · 13 comments

Comments

@btlvr
Copy link
Contributor

btlvr commented Feb 14, 2020

I'm using NixOS 19.09, and I'm unable to use pyplot from within ipython. It works in a normal Python interpreter.

λ python3.7
Python 3.7.5 (default, Oct 14 2019, 23:08:55) 
[GCC 8.3.0] on linux
Type "help", "copyright", "credits" or "license" for more information.
>>> import matplotlib.pyplot as plt
>>> quit()
λ 
λ ipython3
Python 3.7.5 (default, Oct 14 2019, 23:08:55) 
Type 'copyright', 'credits' or 'license' for more information
IPython 7.6.1 -- An enhanced Interactive Python. Type '?' for help.

In [1]: import matplotlib.pyplot as plt                                                                                                                                                                 

In [2]: qt.qpa.plugin: Could not find the Qt platform plugin "xcb" in ""                                                                                                                                
This application failed to start because no Qt platform plugin could be initialized. Reinstalling the application may fix this problem.

zsh: abort (core dumped)  ipython3
λ    

@FRidh
Copy link
Member

FRidh commented Feb 15, 2020

How did you bring python and ipython in your environment?

@rnhmjoj
Copy link
Contributor

rnhmjoj commented Feb 17, 2020

Strangely enough, I'm getting the exact same problem in standard CPython interpreter, so it's probably not an issue in ipython.

How did you bring python and ipython in your environment?

let
    python' = python3.override {
      packageOverrides = self: super: {
        matplotlib = super.matplotlib.override { enableQt = true; };
      };
    };
in python'.withPackages (p: [ p.matplotlib ]);

Here I'm on nixos 20.03 (ceb90b0).

@rnhmjoj
Copy link
Contributor

rnhmjoj commented Feb 21, 2020

I'm linking the issue related to this: #25351 #53816.
I guess something recently changed because the Qt backend used to work: I'll try bisecting.

@wucke13
Copy link
Contributor

wucke13 commented Feb 25, 2020

Just a small heads-up: use the matplotlib TK backend in the meantime, it is sleek and works.

@FRidh
Copy link
Member

FRidh commented Feb 29, 2020

I think matplotlib should propagate the wrap Qt hook when Qt is included in matplotlib. In Python's buildEnv we should then include qtWrapperArgs[@].

@rnhmjoj
Copy link
Contributor

rnhmjoj commented Feb 29, 2020

@FRidh: I like the idea. To be sure, do you mean the python.withPackages defined here? I could try to implement it: it doesn't seem too difficult.

@stale
Copy link

stale bot commented Aug 28, 2020

Hello, I'm a bot and I thank you in the name of the community for opening this issue.

To help our human contributors focus on the most-relevant reports, I check up on old issues to see if they're still relevant. This issue has had no activity for 180 days, and so I marked it as stale, but you can rest assured it will never be closed by a non-human.

The community would appreciate your effort in checking if the issue is still valid. If it isn't, please close it.

If the issue persists, and you'd like to remove the stale label, you simply need to leave a comment. Your comment can be as simple as "still important to me". If you'd like it to get more attention, you can ask for help by searching for maintainers and people that previously touched related code and @ mention them in a comment. You can use Git blame or GitHub's web interface on the relevant files to find them.

Lastly, you can always ask for help at our Discourse Forum or at #nixos' IRC channel.

@stale stale bot added the 2.status: stale https://github.com/NixOS/nixpkgs/blob/master/.github/STALE-BOT.md label Aug 28, 2020
@rnhmjoj
Copy link
Contributor

rnhmjoj commented Aug 30, 2020

It's still an open problem.

@stale stale bot removed the 2.status: stale https://github.com/NixOS/nixpkgs/blob/master/.github/STALE-BOT.md label Aug 30, 2020
@bhipple
Copy link
Contributor

bhipple commented Feb 24, 2021

Is there a recommended workaround for QT support in matplotlib?

@rnhmjoj
Copy link
Contributor

rnhmjoj commented Feb 24, 2021

I had a working proposal that could have made it into 20.09, but it has been scrapped in favour of more complex solution (#102949), which seems stalled :(.

If you really need this to work, try creating a shell.nix in which you define the variables set by makeWrapper. We are lucky matplotlib backend doesn't require any qml/qt plugin except the base, so this should be enough:

let
  pkgs = import <nixpkgs> { };

  matplotlib = pkgs.python3Packages.matplotlib.override { enableQt = true; };

in
  pkgs.mkShell {
    buildInputs = [ matplotlib ];

    QT_PLUGIN_PATH = with pkgs.qt5; "${qtbase}/${qtbase.qtPluginPrefix}";

    shellHook = "python -i";
  }

@stale
Copy link

stale bot commented Aug 28, 2021

I marked this as stale due to inactivity. → More info

@stale stale bot added the 2.status: stale https://github.com/NixOS/nixpkgs/blob/master/.github/STALE-BOT.md label Aug 28, 2021
@rnhmjoj
Copy link
Contributor

rnhmjoj commented Feb 10, 2022

Still an issue

@stale stale bot removed the 2.status: stale https://github.com/NixOS/nixpkgs/blob/master/.github/STALE-BOT.md label Feb 10, 2022
@jamesdbrock
Copy link

See also #236770

stejcon added a commit to stejcon/autobranched-nn that referenced this issue Feb 9, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

7 participants