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

python{2,3}.pkgs.gobject3 with GTK3 - not found? #39637

Open
ashgillman opened this issue Apr 28, 2018 · 7 comments
Open

python{2,3}.pkgs.gobject3 with GTK3 - not found? #39637

ashgillman opened this issue Apr 28, 2018 · 7 comments
Labels
2.status: stale https://github.com/NixOS/nixpkgs/blob/master/.github/STALE-BOT.md 6.topic: python

Comments

@ashgillman
Copy link
Contributor

Issue description

Matplotlib with the GTK3 backend doesn't seem to be working. However, I am not actually sure how this feature is intended to be used.

Steps to reproduce

# matplotlib.nix
with import <nixpkgs> {};
# (python3.withPackages (pkgs: with pkgs; [ (matplotlib.override { enableGtk3 = true; }) ])).env
(python2.withPackages (pkgs: with pkgs; [ (matplotlib.override { enableGtk3 = true; }) ])).env
$ nix-shell matplotlib.nix
[nix-shell:~/tmp]$ MPLBACKEND=GTK3Cairo python
Python 2.7.14 (default, Sep 16 2017, 17:49:51)
[GCC 6.4.0] on linux2
Type "help", "copyright", "credits" or "license" for more information.
>>> from matplotlib import pyplot as plt
Traceback (most recent call last):
  File "<stdin>", line 1, in <module>
  File "/nix/store/v90d6zrgljzvjvibm97ssm9pm0ha8bin-python-2.7.14-env/lib/python2.7/site-packages/matplotlib/pyplot.py", line 115, in <module>
    _backend_mod, new_figure_manager, draw_if_interactive, _show = pylab_setup()
  File "/nix/store/v90d6zrgljzvjvibm97ssm9pm0ha8bin-python-2.7.14-env/lib/python2.7/site-packages/matplotlib/backends/__init__.py", line 32, in pylab_setup
    globals(),locals(),[backend_name],0)
  File "/nix/store/v90d6zrgljzvjvibm97ssm9pm0ha8bin-python-2.7.14-env/lib/python2.7/site-packages/matplotlib/backends/backend_gtk3cairo.py", line 6, in <module>
    from . import backend_gtk3
  File "/nix/store/v90d6zrgljzvjvibm97ssm9pm0ha8bin-python-2.7.14-env/lib/python2.7/site-packages/matplotlib/backends/backend_gtk3.py", line 21, in <module>
    "Gtk3 backend requires the GObject introspection bindings for Gtk 3 "
ImportError: Gtk3 backend requires the GObject introspection bindings for Gtk 3 to be installed.
>>>

Technical details

Please run nix-shell -p nix-info --run "nix-info -m" and paste the
results.

  • system: "x86_64-linux"
  • host os: Linux 4.13.0-38-generic, Ubuntu, 16.04.4 LTS (Xenial Xerus)
  • multi-user?: no
  • sandbox: no
  • version: nix-env (Nix) 2.0
  • channels(gil2a4): "nixpkgs-18.03pre126020.931a0b8be80"
  • channels(root): ""
  • nixpkgs: /etc/nixpkgs

^ have also run on the latest 18.03

@ashgillman
Copy link
Contributor Author

Actually,

$ nix-shell -p 'python3.pkgs.matplotlib.override { enableGtk3 = true; }'

Seems to work. Why doesn't my first method?

@jtojnar
Copy link
Member

jtojnar commented Apr 28, 2018

Duplicate of #39637?

GObject bindings require some environments variables to be set (at least GI_TYPELIB_PATH). In normal case, gobjectIntrospecion’s setup hook would populate it, and then wrapGAppsHook would wrap the executable files. With python libraries, there is no executable to be wrapped, but in some cases the variables might get into the shell. I am not exactly sure about nix-shell semantics, but something like the following might work:

# matplotlib.nix
with import <nixpkgs> {};

let
  matplotlib = python3.pkgs.matplotlib.override { enableGtk3 = true; };
in stdenv.mkDerivation rec {
  name = "my-statistics-tools";

  buildInputs = [
    python
    matplotlib # probably needs to be separate for environment variables to propagate correctly
  ];

  shellHook = ''
    MPLBACKEND=GTK3Cairo exec python
  '';
}

It segfaults for me, though.

@ashgillman
Copy link
Contributor Author

@jtojnar You tagged this issue as the duplicate by accident :)

@jtojnar
Copy link
Member

jtojnar commented Apr 30, 2018

Right, I meant #25351

@balsoft
Copy link
Member

balsoft commented May 31, 2018

@jtojnar I have a similar issue of python segfaulting when I try to import Gtk from gi.repository.
My script:

#!/usr/bin/env nix-shell
#!nix-shell -p python36Packages.pygobject3 -p gobjectIntrospection -p gtk3 -i python3

import gi
gi.require_version("Gtk", "3.0")
from gi.repository import Gtk

Results in Segmentation fault every time.

@ashgillman ashgillman changed the title python{2,3}.pkgs.matplotlib with enableGtk3 not working python{2,3}.pkgs.gobject3 with GTK3 - not found? May 31, 2018
@stale
Copy link

stale bot commented Jun 4, 2020

Thank you for your contributions.

This has been automatically marked as stale because it has had no activity for 180 days.

If this is still important to you, we ask that you leave a comment below. Your comment can be as simple as "still important to me". This lets people see that at least one person still cares about this. Someone will have to do this at most twice a year if there is no other activity.

Here are suggestions that might help resolve this more quickly:

  1. Search for maintainers and people that previously touched the related code and @ mention them in a comment.
  2. Ask on the NixOS Discourse.
  3. Ask on the #nixos channel on irc.freenode.net.

@stale stale bot added the 2.status: stale https://github.com/NixOS/nixpkgs/blob/master/.github/STALE-BOT.md label Jun 4, 2020
@nixos-discourse
Copy link

This issue has been mentioned on NixOS Discourse. There might be relevant details there:

https://discourse.nixos.org/t/python-matplotlib-gtk-backend-not-working/17419/5

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
2.status: stale https://github.com/NixOS/nixpkgs/blob/master/.github/STALE-BOT.md 6.topic: python
Projects
None yet
Development

No branches or pull requests

5 participants