Error installing audiocraft/musicgen

Installation process: audiocraft/README.md at main · facebookresearch/audiocraft · GitHub
I’ve installed python using cachix as per How to install python3.9 - #2 by scallop_risotto
This is all done in a venv created with python -m venv env and entered with source env/bin/activate
~/audiocraft contains the following:

~/audiocraft]$ ls
assets               config           egs               Makefile     requirements.txt
audiocraft           CONTRIBUTING.md  env               MANIFEST.in  scripts
audiocraft.egg-info  dataset          jasco_demo.ipynb  model_cards  setup.cfg
CHANGELOG.md         demos            LICENSE           mypy.ini     setup.py
CODE_OF_CONDUCT.md   docs             LICENSE_weights   README.md    tests

Here is the error provided by the final installation step detailed in the Installation Guide

[user@nixos:~/audiocraft]$ python3.9 -m pip install -U audiocraft #same error with `python3.9 -m pip install -e .`
Collecting audiocraft
  Using cached audiocraft-1.3.0.tar.gz (635 kB)
  Preparing metadata (setup.py) ... done
Collecting av==11.0.0
  Using cached av-11.0.0.tar.gz (3.7 MB)
  Installing build dependencies ... done
  Getting requirements to build wheel ... error
  error: subprocess-exited-with-error
  
  × Getting requirements to build wheel did not run successfully.
  │ exit code: 1
  ╰─> [29 lines of output]
      Package libavformat was not found in the pkg-config search path.
      Perhaps you should add the directory containing `libavformat.pc'
      to the PKG_CONFIG_PATH environment variable
      No package 'libavformat' found
      Package libavcodec was not found in the pkg-config search path.
      Perhaps you should add the directory containing `libavcodec.pc'
      to the PKG_CONFIG_PATH environment variable
      No package 'libavcodec' found
      Package libavdevice was not found in the pkg-config search path.
      Perhaps you should add the directory containing `libavdevice.pc'
      to the PKG_CONFIG_PATH environment variable
      No package 'libavdevice' found
      Package libavutil was not found in the pkg-config search path.
      Perhaps you should add the directory containing `libavutil.pc'
      to the PKG_CONFIG_PATH environment variable
      No package 'libavutil' found
      Package libavfilter was not found in the pkg-config search path.
      Perhaps you should add the directory containing `libavfilter.pc'
      to the PKG_CONFIG_PATH environment variable
      No package 'libavfilter' found
      Package libswscale was not found in the pkg-config search path.
      Perhaps you should add the directory containing `libswscale.pc'
      to the PKG_CONFIG_PATH environment variable
      No package 'libswscale' found
      Package libswresample was not found in the pkg-config search path.
      Perhaps you should add the directory containing `libswresample.pc'
      to the PKG_CONFIG_PATH environment variable
      No package 'libswresample' found
      pkg-config could not find libraries ['avformat', 'avcodec', 'avdevice', 'avutil', 'avfilter', 'swscale', 'swresample']
      [end of output]
  
  note: This error originates from a subprocess, and is likely not a problem with pip.
error: subprocess-exited-with-error

× Getting requirements to build wheel did not run successfully.
│ exit code: 1
╰─> See above for output.

note: This error originates from a subprocess, and is likely not a problem with pip.
WARNING: There was an error checking the latest version of pip.
(env)

if python309Packages.av existed this wouldn’t be a problem - is there an archive of python309Packages, if that ever existed, that I can install av and any other packages that it appears I can’t install from pip on NixOS? If so, how do I install from it - I’ve gone through nixpkgs/pkgs/development/interpreters/python at master · NixOS/nixpkgs · GitHub but am not familiar with how to benefit from scrolling through commit history of nixpkgs.

I’d take a look at https://lazamar.co.uk/nix-versions/?channel=nixpkgs-unstable&package=python39, not 100% sure if it’s still maintained but this at least has some historical data. It shows commit ids where python39 still existed, along with all its updates.

1 Like

This appears to be only python3.9 binaries - was this mentioned so I could in theory find where the commit hash for python309Packages or whichever python3.9-supporting av package could be installed with nix?

Python packages in nixpkgs are sort of independent of the python version. So if you have python39 and the av python package then python39Packages.av will exist. So the main thing you’re looking for is a commit where python39 still existed.

ok - because when running pip install -U audiocraft command from op inside nix-shell -p ffmpeg ffmpeg.dev pkg-config python313Packages.spacy python313Packages.av I still seem to get the error in op — either a python3.9-specific av or libsw library needs to be installed via Nix or the solution to op is unrelated.

From your response I’m unsure if you’re suggesting I somehow revert to an earlier nixos channel or installing python3.9 at all so I’ll note that I have installed python3.9 already via

cachix use nixpkgs-python
nix shell github:cachix/nixpkgs-python#'"3.9"'

as suggested here

I don’t know how to use cachix, so I’d write a shell.nix that looks like

let
    pkgs = import (builtins.fetchTarball {
        url = "https://github.com/NixOS/nixpkgs/archive/c5dd43934613ae0f8ff37c59f61c507c2e8f980d.tar.gz";
    }) {};
in
pkgs.mkShell {
  packages = [
    (pkgs.python39.withPackages (p: [
      p.av
    ]))
  ];
}

then run nix-shell.

The fetchTarball bit is copied from “Use python3 in a nix script via tarball” when you click on the commit in the link I provided earlier.

unpacking 'https://github.com/NixOS/nixpkgs/archive/c5dd43934613ae0f8ff37c59f61c507c2e8f980d.tar.gz' into the Git cache...
error:
       … while calling the 'derivationStrict' builtin
         at <nix/derivation-internal.nix>:37:12:
           36|
           37|   strict = derivationStrict drvAttrs;
             |            ^
           38|

       … while evaluating derivation 'nix-shell'
         whose name attribute is located at /nix/store/gn3wd29qpr1il1l2x97vnjrclijjbv9d-source/pkgs/stdenv/generic/make-derivation.nix:375:7

       … while evaluating attribute 'nativeBuildInputs' of derivation 'nix-shell'
         at /nix/store/gn3wd29qpr1il1l2x97vnjrclijjbv9d-source/pkgs/stdenv/generic/make-derivation.nix:419:7:
          418|       depsBuildBuild              = elemAt (elemAt dependencies 0) 0;
          419|       nativeBuildInputs           = elemAt (elemAt dependencies 0) 1;
             |       ^
          420|       depsBuildTarget             = elemAt (elemAt dependencies 0) 2;

       (stack trace truncated; use '--show-trace' to show the full, detailed trace)

       error: Dependency is not of a valid type: element 1 of nativeBuildInputs for nix-shell

Needs parentheses… fixed my example.

error:
       … while calling the 'derivationStrict' builtin
         at <nix/derivation-internal.nix>:37:12:
           36|
           37|   strict = derivationStrict drvAttrs;
             |            ^
           38|

       … while evaluating derivation 'nix-shell'
         whose name attribute is located at /nix/store/gn3wd29qpr1il1l2x97vnjrclijjbv9d-source/pkgs/stdenv/generic/make-derivation.nix:375:7

       … while evaluating attribute 'nativeBuildInputs' of derivation 'nix-shell'
         at /nix/store/gn3wd29qpr1il1l2x97vnjrclijjbv9d-source/pkgs/stdenv/generic/make-derivation.nix:419:7:
          418|       depsBuildBuild              = elemAt (elemAt dependencies 0) 0;
          419|       nativeBuildInputs           = elemAt (elemAt dependencies 0) 1;
             |       ^
          420|       depsBuildTarget             = elemAt (elemAt dependencies 0) 2;

       (stack trace truncated; use '--show-trace' to show the full, detailed trace)

       error: numpy-2.2.3 not supported for interpreter python3.9

Yeah, I can’t help there, as it’s an older commit. You’ll have to bisect a bunch and find a commit where numpy works with python 3.9. I’d start by going to that github commit and using the blame option on the numpy expression to see when the restriction was added, then work backwards.

yeah - I’ve been trying to get
nix-repl> builtins.attrNames packages.x86_64-linux."3.9".pkgs.av
to work but am running into similar problems just figuring out what exactly it is and getting it to work — it’s from the same repo that my working python3.9 binary on NixOS came from.

Also I’ll try your most recent response, although I’ll have to figure out what bisecting and blame option mean on Nix.

These are git concepts, not nix ones.

I mentioned to use github’s web interface for the blame part as it might be easier to read the output. They also have a “history” link to show you the past commits made on that file. But that’s up to you.

has anyone ever successfully installed/ran audiocraft/musicgen on NixOS

also I’ve tried to build blender from source on nixos and haven’t done so yet.

does anyone have a valid method of doing so that actually works