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

python3*Packages.pymupdf: Runtime import failure in buildEnv #332384

Open
mockuser404 opened this issue Aug 5, 2024 · 4 comments · Fixed by #332385
Open

python3*Packages.pymupdf: Runtime import failure in buildEnv #332384

mockuser404 opened this issue Aug 5, 2024 · 4 comments · Fixed by #332385
Labels

Comments

@mockuser404
Copy link

Describe the bug

When using nixpkgs stable (nixos-24.05) the packages python312Packages.pymupdf and python311Packages.pymupdf both are not working properly in a nix shell env.

Steps To Reproduce

Steps to reproduce the behavior:

# flake.nix
{
  description = "test pymupdf devshell";
  inputs = {
    nixpkgs.url = "github:nixos/nixpkgs?ref=nixos-24.05";
  };
  outputs =
    { self, nixpkgs, ... }:
    let
      system = "x86_64-linux";
      pkgs = import nixpkgs { inherit system; };
    in
    {
      devShells.${system}.default = pkgs.mkShell {
        packages = [
          (pkgs.python312.withPackages (pp: with pp; [ pymupdf ]))
        ];
      };
    };
}

Now check in the devshell

$ nix develop
$ python
>>> import fitz
Traceback (most recent call last):
  File "/nix/store/qv31saxij43ncc1r2891ck4vnjfav9jz-python3-3.12.4-env/lib/python3.12/site-packages/fitz/__init__.py", line 140, in <module>
    from . import mupdf
ImportError: cannot import name 'mupdf' from partially initialized module 'fitz' (most likely due to a circular import) (/nix/store/qv31saxij43ncc1r2891ck4vnjfav9jz-python3-3.12.4-env/lib/python3.12/site-packages/fitz/__init__.py)

During handling of the above exception, another exception occurred:

Traceback (most recent call last):
  File "<stdin>", line 1, in <module>
  File "/nix/store/qv31saxij43ncc1r2891ck4vnjfav9jz-python3-3.12.4-env/lib/python3.12/site-packages/fitz/__init__.py", line 142, in <module>
    import mupdf
ModuleNotFoundError: No module named 'mupdf'

Expected behavior

pymupdf gets imported properly since this is approved in nixos stable.

Additional context

Notify maintainers

@teto

Metadata

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

[user@system:~]$ nix-shell -p nix-info --run "nix-info -m"
 - system: `"x86_64-linux"`
 - host os: `Linux 6.6.43, NixOS, 24.11 (Vicuna), 24.11.20240804.5d97d39`
 - multi-user?: `yes`
 - sandbox: `relaxed`
 - version: `nix-env (Nix) 2.18.5`
 - channels(root): `"nixos"`
 - nixpkgs: `/nix/store/x2lvdghyrpvkifz0k910garzbd3wpjdg-source`

Add a 👍 reaction to issues you find important.

@mockuser404
Copy link
Author

I tried the patch from #332385 and it didn't fix this issue. Can someone tell me if this is a real issue or if I'm doing something wrong here. I wish to simply use pymupdf to write some python code on Nixos to extract embedded videos from pdf.

I tried with nixpkgs.url = "github:greg-hellings/nixpkgs?ref=browsr-1.21.0"; and have the same issue.

@eclairevoyant
Copy link
Contributor

python3Packages.pymupdf works, python3.withPackages (p: [ p.pymupdf ]) doesn't.

Can't say I know why though 🥲

@mockuser404
Copy link
Author

Thank you. I got it working with

    devShells.${system}.default = pkgs.mkShell {
      venvDir = "./venv";
      buildInputs = with pkgs.python312Packages; [
        venvShellHook
        python
        pymupdf
        icecream
      ];
      # ...
    };

It's not related to #332385 in any way then. I don't know enough nix to debug why this works and why the first doesn't, it is a bug so, I am leaving this issue open even though there is a workaround.

@eclairevoyant eclairevoyant changed the title Runtime import failure: python312Packages.pymupdf on stable. python3*Packages.pymupdf: Runtime import failure in buildEnv Aug 6, 2024
@charmoniumQ
Copy link
Contributor

charmoniumQ commented Sep 11, 2024

Addressed by #334596

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