Skip to content

Camelot fails because of missing ghostscript dependency #362939

@matthuszagh

Description

@matthuszagh

Take the following flake (nixpkgs rev is 1e56a3b):

{
  inputs.nixpkgs.url = github:nixos/nixpkgs;

  outputs =
    { self
    , nixpkgs
    }: {
      devShell.x86_64-linux =
        let
          system = "x86_64-linux";
          pkgs = (import nixpkgs { inherit system; }).pkgs;
        in
        pkgs.mkShell {
          buildInputs = (with pkgs; [
            (python3.withPackages (p: with p; [
              camelot
            ]))
          ]);
        };
    };
}

Now, start python and (or presumably use any other PDF)

import camelot
tables = camelot.read_pdf("tlv3511-q1.pdf")

This emits the error:

Traceback (most recent call last):
  File "<stdin>", line 1, in <module>
  File "/nix/store/8kbmmpb8r84y89132q6bpcj85an1n0sv-python3-3.12.7-env/lib/python3.12/site-packages/camelot/io.py", line 113, in read_pdf
    tables = p.parse(
             ^^^^^^^^
  File "/nix/store/8kbmmpb8r84y89132q6bpcj85an1n0sv-python3-3.12.7-env/lib/python3.12/site-packages/camelot/handlers.py", line 176, in parse
    t = parser.extract_tables(
        ^^^^^^^^^^^^^^^^^^^^^^
  File "/nix/store/8kbmmpb8r84y89132q6bpcj85an1n0sv-python3-3.12.7-env/lib/python3.12/site-packages/camelot/parsers/lattice.py", line 421, in extract_tables
    self.backend.convert(self.filename, self.imagename)
  File "/nix/store/8kbmmpb8r84y89132q6bpcj85an1n0sv-python3-3.12.7-env/lib/python3.12/site-packages/camelot/backends/ghostscript_backend.py", line 31, in convert
    raise OSError(
OSError: Ghostscript is not installed. You can install it using the instructions here: https://camelot-py.readthedocs.io/en/master/user/install-deps.html

I can explicitly provide ghostscript in the flake with (though it should be a runtime dependency)

{
  inputs.nixpkgs.url = github:nixos/nixpkgs;

  outputs =
    { self
    , nixpkgs
    }: {
      devShell.x86_64-linux =
        let
          system = "x86_64-linux";
          pkgs = (import nixpkgs { inherit system; }).pkgs;
        in
        pkgs.mkShell {
          buildInputs = (with pkgs; [
            (python3.withPackages (p: with p; [
              camelot
            ]))
            ghostscript
          ]);
        };
    };
}

Then, the error is

Traceback (most recent call last):
  File "<stdin>", line 1, in <module>
  File "/nix/store/8kbmmpb8r84y89132q6bpcj85an1n0sv-python3-3.12.7-env/lib/python3.12/site-packages/camelot/io.py", line 113, in read_pdf
    tables = p.parse(
             ^^^^^^^^
  File "/nix/store/8kbmmpb8r84y89132q6bpcj85an1n0sv-python3-3.12.7-env/lib/python3.12/site-packages/camelot/handlers.py", line 176, in parse
    t = parser.extract_tables(
        ^^^^^^^^^^^^^^^^^^^^^^
  File "/nix/store/8kbmmpb8r84y89132q6bpcj85an1n0sv-python3-3.12.7-env/lib/python3.12/site-packages/camelot/parsers/lattice.py", line 421, in extract_tables
    self.backend.convert(self.filename, self.imagename)
  File "/nix/store/8kbmmpb8r84y89132q6bpcj85an1n0sv-python3-3.12.7-env/lib/python3.12/site-packages/camelot/backends/ghostscript_backend.py", line 36, in convert
    import ghostscript
ModuleNotFoundError: No module named 'ghostscript'

@2gn @bcdarwin

Metadata

Metadata

Assignees

No one assigned

    Labels

    0.kind: bugSomething is broken2.status: stalehttps://github.com/NixOS/nixpkgs/blob/master/.github/STALE-BOT.md

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions