Qiskit-terra-0.25.1 not supported for interpreter python3.11

I am very new to Nixos and am trying to create a Jupyter notebook to run some Qiskit functions (on OSX). My code is:

{ pkgs ? import (fetchTarball "https://github.com/NixOS/nixpkgs/archive/nixos-unstable.tar.gz") {} }:

let
  my-python-packages = python-packages: with python-packages; [
    matplotlib
    numpy
    pandas
    scipy
    qiskit
  ];
  python-with-my-packages = pkgs.python311.withPackages my-python-packages;
in
pkgs.mkShell {
  buildInputs = [
    python-with-my-packages
  ];
}

And I am running it with: nix-shell --run “jupyter lab”

When I do it fails with the following error:

error:
       … while calling the 'derivationStrict' builtin

         at /derivation-internal.nix:9:12:

            8|
            9|   strict = derivationStrict drvAttrs;
             |            ^
           10|

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

       … while evaluating attribute 'buildInputs' of derivation 'nix-shell'

         at /nix/store/4fgs7yzsy2dqnjw8j42qlp9i1vgarzy0-source/pkgs/stdenv/generic/make-derivation.nix:395:7:

          394|       depsHostHost                = elemAt (elemAt dependencies 1) 0;
          395|       buildInputs                 = elemAt (elemAt dependencies 1) 1;
             |       ^
          396|       depsTargetTarget            = elemAt (elemAt dependencies 2) 0;

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

       error: qiskit-terra-0.25.1 not supported for interpreter python3.11

To me, the key failure seems to be related to Qiskit-Terra due to

error: qiskit-terra-0.25.1 not supported for interpreter python3.11

When I check the status of Qiskit-Terra it appears to be compatible.

REF: NixOS Search

Any help would be greatly appreciated!

You can reproduce this by evaluating just python311Packages.qiskit-terra, which is currently marked as disabled for Python 3.11 pending an update. You might have success using python310 instead.

I updated my script to the following but still get an error. I am terribly new at this and am probably misinterpreting the documentation.

{ pkgs ? import (fetchTarball "https://github.com/NixOS/nixpkgs/archive/nixos-unstable.tar.gz") {} }:

let
  my-python-packages = python-packages: with python-packages; [
    matplotlib
    numpy
    pandas
    scipy
    qiskit
  ];
  python-with-my-packages = pkgs.python310.withPackages my-python-packages;
in
pkgs.mkShell {
  buildInputs = [
    python-with-my-packages
  ];

  shellHook = ''
    # Set NIXPKGS_ALLOW_BROKEN to 1
    export NIXPKGS_ALLOW_BROKEN=1
    echo "NIXPKGS_ALLOW_BROKEN is set to $NIXPKGS_ALLOW_BROKEN"
  '';
}

The error produuced is

error:
       … while calling the 'derivationStrict' builtin

         at /derivation-internal.nix:9:12:

            8|
            9|   strict = derivationStrict drvAttrs;
             |            ^
           10|

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

       … while evaluating attribute 'buildInputs' of derivation 'nix-shell'

         at /nix/store/4fgs7yzsy2dqnjw8j42qlp9i1vgarzy0-source/pkgs/stdenv/generic/make-derivation.nix:395:7:

          394|       depsHostHost                = elemAt (elemAt dependencies 1) 0;
          395|       buildInputs                 = elemAt (elemAt dependencies 1) 1;
             |       ^
          396|       depsTargetTarget            = elemAt (elemAt dependencies 2) 0;

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

       error: Package ‘python3.10-qiskit-aer-0.12.2’ in /nix/store/4fgs7yzsy2dqnjw8j42qlp9i1vgarzy0-source/pkgs/development/python-modules/qiskit-aer/default.nix:151 is marked as broken, refusing to evaluate.

       a) To temporarily allow broken packages, you can use an environment variable
          for a single invocation of the nix tools.

            $ export NIXPKGS_ALLOW_BROKEN=1

          Note: When using `nix shell`, `nix build`, `nix develop`, etc with a flake,
                then pass `--impure` in order to allow use of environment variables.

       b) For `nixos-rebuild` you can set
         { nixpkgs.config.allowBroken = true; }
       in configuration.nix to override this.

       c) For `nix-env`, `nix-build`, `nix-shell` or any other Nix command you can add
         { allowBroken = true; }
       to ~/.config/nixpkgs/config.nix.

Changing (bolded) the script to

{ pkgs ? let
    config = {
      **allowBroken = true;**
    };
    in import (fetchTarball "https://github.com/NixOS/nixpkgs/archive/nixos-unstable.tar.gz") { inherit config; }
}:

let
  my-python-packages = python-packages: with python-packages; [
    matplotlib
    numpy
    pandas
    scipy
    qiskit
  ];
  python-with-my-packages = pkgs.python310.withPackages my-python-packages;
in
pkgs.mkShell {
  buildInputs = [
    python-with-my-packages
  ];

  shellHook = ''
    echo "Welcome to your Nix shell with Python packages!"
  '';
}

I get the error

error:
       … while calling the 'derivationStrict' builtin

         at /derivation-internal.nix:9:12:

            8|
            9|   strict = derivationStrict drvAttrs;
             |            ^
           10|

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

       … while evaluating attribute 'buildInputs' of derivation 'nix-shell'

         at /nix/store/4fgs7yzsy2dqnjw8j42qlp9i1vgarzy0-source/pkgs/stdenv/generic/make-derivation.nix:395:7:

          394|       depsHostHost                = elemAt (elemAt dependencies 1) 0;
          395|       buildInputs                 = elemAt (elemAt dependencies 1) 1;
             |       ^
          396|       depsTargetTarget            = elemAt (elemAt dependencies 2) 0;

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

       error: Unsupported Nix system: aarch64-darwin

Adding in “–show-trace” I get the following

error:
       … while calling the 'derivationStrict' builtin

         at /derivation-internal.nix:9:12:

            8|
            9|   strict = derivationStrict drvAttrs;
             |            ^
           10|

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

       … while evaluating attribute 'buildInputs' of derivation 'nix-shell'

         at /nix/store/4fgs7yzsy2dqnjw8j42qlp9i1vgarzy0-source/pkgs/stdenv/generic/make-derivation.nix:395:7:

          394|       depsHostHost                = elemAt (elemAt dependencies 1) 0;
          395|       buildInputs                 = elemAt (elemAt dependencies 1) 1;
             |       ^
          396|       depsTargetTarget            = elemAt (elemAt dependencies 2) 0;

       … while evaluating derivation 'python3-3.10.13-env'
         whose name attribute is located at /nix/store/4fgs7yzsy2dqnjw8j42qlp9i1vgarzy0-source/pkgs/stdenv/generic/make-derivation.nix:348:7

       … while evaluating attribute 'passAsFile' of derivation 'python3-3.10.13-env'

         at /nix/store/4fgs7yzsy2dqnjw8j42qlp9i1vgarzy0-source/pkgs/build-support/trivial-builders/default.nix:88:7:

           87|       inherit buildCommand name;
           88|       passAsFile = [ "buildCommand" ]
             |       ^
           89|         ++ (derivationArgs.passAsFile or []);

       … from call site

         at /nix/store/4fgs7yzsy2dqnjw8j42qlp9i1vgarzy0-source/pkgs/development/interpreters/python/wrapper.nix:20:13:

           19|   env = let
           20|     paths = requiredPythonModules (extraLibs ++ [ python ] ) ;
             |             ^
           21|     pythonPath = "${placeholder "out"}/${python.sitePackages}";

       … while calling 'requiredPythonModules'

         at /nix/store/4fgs7yzsy2dqnjw8j42qlp9i1vgarzy0-source/pkgs/development/interpreters/python/python-packages-base.nix:57:27:

           56|   # Get list of required Python modules given a list of derivations.
           57|   requiredPythonModules = drvs: let
             |                           ^
           58|     modules = lib.filter hasPythonModule drvs;

       … from call site

         at /nix/store/4fgs7yzsy2dqnjw8j42qlp9i1vgarzy0-source/pkgs/development/interpreters/python/python-packages-base.nix:59:6:

           58|     modules = lib.filter hasPythonModule drvs;
           59|   in lib.unique ([python] ++ modules ++ lib.concatLists (lib.catAttrs "requiredPythonModules" modules));
             |      ^
           60|

       … while calling 'foldl''

         at /nix/store/4fgs7yzsy2dqnjw8j42qlp9i1vgarzy0-source/lib/lists.nix:139:5:

          138|     # The list to fold
          139|     list:
             |     ^
          140|

       … from call site

         at /nix/store/4fgs7yzsy2dqnjw8j42qlp9i1vgarzy0-source/pkgs/development/interpreters/python/python-packages-base.nix:74:33:

           73|         pythonPath = [ ]; # Deprecated, for compatibility.
           74|         requiredPythonModules = requiredPythonModules drv.propagatedBuildInputs;
             |                                 ^
           75|       };

       … while calling 'requiredPythonModules'

         at /nix/store/4fgs7yzsy2dqnjw8j42qlp9i1vgarzy0-source/pkgs/development/interpreters/python/python-packages-base.nix:57:27:

           56|   # Get list of required Python modules given a list of derivations.
           57|   requiredPythonModules = drvs: let
             |                           ^
           58|     modules = lib.filter hasPythonModule drvs;

       … from call site

         at /nix/store/4fgs7yzsy2dqnjw8j42qlp9i1vgarzy0-source/pkgs/development/interpreters/python/python-packages-base.nix:59:6:

           58|     modules = lib.filter hasPythonModule drvs;
           59|   in lib.unique ([python] ++ modules ++ lib.concatLists (lib.catAttrs "requiredPythonModules" modules));
             |      ^
           60|

       … while calling 'foldl''

         at /nix/store/4fgs7yzsy2dqnjw8j42qlp9i1vgarzy0-source/lib/lists.nix:139:5:

          138|     # The list to fold
          139|     list:
             |     ^
          140|

       … from call site

         at /nix/store/4fgs7yzsy2dqnjw8j42qlp9i1vgarzy0-source/pkgs/development/interpreters/python/python-packages-base.nix:74:33:

           73|         pythonPath = [ ]; # Deprecated, for compatibility.
           74|         requiredPythonModules = requiredPythonModules drv.propagatedBuildInputs;
             |                                 ^
           75|       };

       … while calling 'requiredPythonModules'

         at /nix/store/4fgs7yzsy2dqnjw8j42qlp9i1vgarzy0-source/pkgs/development/interpreters/python/python-packages-base.nix:57:27:

           56|   # Get list of required Python modules given a list of derivations.
           57|   requiredPythonModules = drvs: let
             |                           ^
           58|     modules = lib.filter hasPythonModule drvs;

       … from call site

         at /nix/store/4fgs7yzsy2dqnjw8j42qlp9i1vgarzy0-source/pkgs/development/interpreters/python/python-packages-base.nix:59:6:

           58|     modules = lib.filter hasPythonModule drvs;
           59|   in lib.unique ([python] ++ modules ++ lib.concatLists (lib.catAttrs "requiredPythonModules" modules));
             |      ^
           60|

       … while calling 'foldl''

         at /nix/store/4fgs7yzsy2dqnjw8j42qlp9i1vgarzy0-source/lib/lists.nix:139:5:

          138|     # The list to fold
          139|     list:
             |     ^
          140|

       … while calling anonymous lambda

         at /nix/store/4fgs7yzsy2dqnjw8j42qlp9i1vgarzy0-source/lib/lists.nix:864:25:

          863|    */
          864|   unique = foldl' (acc: e: if elem e acc then acc else acc ++ [ e ]) [];
             |                         ^
          865|

       … while evaluating derivation 'python3.10-torch-2.1.1'
         whose name attribute is located at /nix/store/4fgs7yzsy2dqnjw8j42qlp9i1vgarzy0-source/pkgs/stdenv/generic/make-derivation.nix:348:7

       … while evaluating attribute 'USE_NCCL' of derivation 'python3.10-torch-2.1.1'

         at /nix/store/4fgs7yzsy2dqnjw8j42qlp9i1vgarzy0-source/pkgs/development/python-modules/torch/default.nix:276:3:

          275|
          276|   USE_NCCL = setBool (cudaPackages ? nccl);
             |   ^
          277|   USE_SYSTEM_NCCL = setBool useSystemNccl;                  # don't build pytorch's third_party NCCL

       … from call site

         at /nix/store/4fgs7yzsy2dqnjw8j42qlp9i1vgarzy0-source/pkgs/development/python-modules/torch/default.nix:276:14:

          275|
          276|   USE_NCCL = setBool (cudaPackages ? nccl);
             |              ^
          277|   USE_SYSTEM_NCCL = setBool useSystemNccl;                  # don't build pytorch's third_party NCCL

       … while calling 'setBool'

         at /nix/store/4fgs7yzsy2dqnjw8j42qlp9i1vgarzy0-source/pkgs/development/python-modules/torch/default.nix:61:13:

           60|
           61|   setBool = v: if v then "1" else "0";
             |             ^
           62|

       … from call site

         at /nix/store/4fgs7yzsy2dqnjw8j42qlp9i1vgarzy0-source/pkgs/top-level/all-packages.nix:7329:21:

         7328|   cudaPackages_11_8 = callPackage ./cuda-packages.nix { cudaVersion = "11.8"; };
         7329|   cudaPackages_11 = recurseIntoAttrs cudaPackages_11_8;
             |                     ^
         7330|

       … while calling 'recurseIntoAttrs'

         at /nix/store/4fgs7yzsy2dqnjw8j42qlp9i1vgarzy0-source/lib/attrsets.nix:1145:5:

         1144|     # An attribute set to scan for derivations.
         1145|     attrs:
             |     ^
         1146|     attrs // { recurseForDerivations = true; };

       … from call site

         at /nix/store/4fgs7yzsy2dqnjw8j42qlp9i1vgarzy0-source/pkgs/top-level/all-packages.nix:7328:23:

         7327|   cudaPackages_11_7 = callPackage ./cuda-packages.nix { cudaVersion = "11.7"; };
         7328|   cudaPackages_11_8 = callPackage ./cuda-packages.nix { cudaVersion = "11.8"; };
             |                       ^
         7329|   cudaPackages_11 = recurseIntoAttrs cudaPackages_11_8;

       … while calling 'callPackageWith'

         at /nix/store/4fgs7yzsy2dqnjw8j42qlp9i1vgarzy0-source/lib/customisation.nix:153:35:

          152|   */
          153|   callPackageWith = autoArgs: fn: args:
             |                                   ^
          154|     let

       … from call site

         at /nix/store/4fgs7yzsy2dqnjw8j42qlp9i1vgarzy0-source/lib/trivial.nix:440:7:

          439|     { # TODO: Should we add call-time "type" checking like built in?
          440|       __functor = self: f;
             |       ^
          441|       __functionArgs = args;

       … while calling anonymous lambda

         at /nix/store/4fgs7yzsy2dqnjw8j42qlp9i1vgarzy0-source/lib/customisation.nix:96:17:

           95|     in
           96|     mirrorArgs (origArgs:
             |                 ^
           97|     let

       … from call site

         at /nix/store/4fgs7yzsy2dqnjw8j42qlp9i1vgarzy0-source/lib/customisation.nix:98:16:

           97|     let
           98|       result = f origArgs;
             |                ^
           99|

       … while calling anonymous lambda

         at /nix/store/4fgs7yzsy2dqnjw8j42qlp9i1vgarzy0-source/pkgs/top-level/cuda-packages.nix:23:1:

           22| # I've (@connorbaker) attempted to do that, though I'm unsure of how this will interact with overrides.
           23| {
             | ^
           24|   callPackage,

       … from call site

         at /nix/store/4fgs7yzsy2dqnjw8j42qlp9i1vgarzy0-source/pkgs/top-level/cuda-packages.nix:117:18:

          116|
          117|   cudaPackages = customisation.makeScope newScope (
             |                  ^
          118|     fixedPoints.extends composedExtension passthruFunction

       … while calling 'makeScope'

         at /nix/store/4fgs7yzsy2dqnjw8j42qlp9i1vgarzy0-source/lib/customisation.nix:317:25:

          316|   */
          317|   makeScope = newScope: f:
             |                         ^
          318|     let self = f self // {

       … from call site

         at /nix/store/4fgs7yzsy2dqnjw8j42qlp9i1vgarzy0-source/lib/customisation.nix:318:16:

          317|   makeScope = newScope: f:
          318|     let self = f self // {
             |                ^
          319|           newScope = scope: newScope (self // scope);

       … while calling 'extends'

         at /nix/store/4fgs7yzsy2dqnjw8j42qlp9i1vgarzy0-source/lib/fixed-points.nix:141:24:

          140|   */
          141|   extends = f: rattrs: self: let super = rattrs self; in super // f self super;
             |                        ^
          142|

       … from call site

         at /nix/store/4fgs7yzsy2dqnjw8j42qlp9i1vgarzy0-source/lib/fixed-points.nix:141:67:

          140|   */
          141|   extends = f: rattrs: self: let super = rattrs self; in super // f self super;
             |                                                                   ^
          142|

       … while calling 'composeExtensions'

         at /nix/store/4fgs7yzsy2dqnjw8j42qlp9i1vgarzy0-source/lib/fixed-points.nix:149:18:

          148|   composeExtensions =
          149|     f: g: final: prev:
             |                  ^
          150|       let fApplied = f final prev;

       … from call site

         at /nix/store/4fgs7yzsy2dqnjw8j42qlp9i1vgarzy0-source/lib/fixed-points.nix:152:22:

          151|           prev' = prev // fApplied;
          152|       in fApplied // g final prev';
             |                      ^
          153|

       … while calling 'composeExtensions'

         at /nix/store/4fgs7yzsy2dqnjw8j42qlp9i1vgarzy0-source/lib/fixed-points.nix:149:18:

          148|   composeExtensions =
          149|     f: g: final: prev:
             |                  ^
          150|       let fApplied = f final prev;

       … from call site

         at /nix/store/4fgs7yzsy2dqnjw8j42qlp9i1vgarzy0-source/lib/fixed-points.nix:152:22:

          151|           prev' = prev // fApplied;
          152|       in fApplied // g final prev';
             |                      ^
          153|

       … while calling 'composeExtensions'

         at /nix/store/4fgs7yzsy2dqnjw8j42qlp9i1vgarzy0-source/lib/fixed-points.nix:149:18:

          148|   composeExtensions =
          149|     f: g: final: prev:
             |                  ^
          150|       let fApplied = f final prev;

       … from call site

         at /nix/store/4fgs7yzsy2dqnjw8j42qlp9i1vgarzy0-source/lib/fixed-points.nix:152:22:

          151|           prev' = prev // fApplied;
          152|       in fApplied // g final prev';
             |                      ^
          153|

       … while calling 'composeExtensions'

         at /nix/store/4fgs7yzsy2dqnjw8j42qlp9i1vgarzy0-source/lib/fixed-points.nix:149:18:

          148|   composeExtensions =
          149|     f: g: final: prev:
             |                  ^
          150|       let fApplied = f final prev;

       … from call site

         at /nix/store/4fgs7yzsy2dqnjw8j42qlp9i1vgarzy0-source/lib/fixed-points.nix:150:22:

          149|     f: g: final: prev:
          150|       let fApplied = f final prev;
             |                      ^
          151|           prev' = prev // fApplied;

       … while calling 'extension'

         at /nix/store/4fgs7yzsy2dqnjw8j42qlp9i1vgarzy0-source/pkgs/development/cuda-modules/generic-builders/multiplex.nix:104:12:

          103|   extension =
          104|     final: _:
             |            ^
          105|     let

       … from call site

         at /nix/store/4fgs7yzsy2dqnjw8j42qlp9i1vgarzy0-source/pkgs/development/cuda-modules/generic-builders/multiplex.nix:86:36:

           85|   # newestToOldestSupportedPackage :: List (AttrSet Packages)
           86|   newestToOldestSupportedPackage = lists.reverseList supportedPackages;
             |                                    ^
           87|

       … while calling 'reverseList'

         at /nix/store/4fgs7yzsy2dqnjw8j42qlp9i1vgarzy0-source/lib/lists.nix:510:17:

          509|   */
          510|   reverseList = xs:
             |                 ^
          511|     let l = length xs; in genList (n: elemAt xs (l - n - 1)) l;

       … from call site

         at /nix/store/4fgs7yzsy2dqnjw8j42qlp9i1vgarzy0-source/pkgs/development/cuda-modules/generic-builders/multiplex.nix:79:16:

           78|   # Get all of the packages for our given platform.
           79|   redistArch = flags.getRedistArch hostPlatform.system;
             |                ^
           80|

       … while calling 'getRedistArch'

         at /nix/store/4fgs7yzsy2dqnjw8j42qlp9i1vgarzy0-source/pkgs/development/cuda-modules/flags.nix:136:5:

          135|   getRedistArch =
          136|     nixSystem:
             |     ^
          137|     if nixSystem == "aarch64-linux" then

       error: Unsupported Nix system: aarch64-darwin

It looks like the Qiskit packages are unmaintained; the last time anyone worked on them was in April 2022 and without updates they eventually became incompatible with the rest of nixpkgs.

Is there any link I could use to understand what’s needed to bring them up to date? I’m new to all of this but am certainly willing to try :slight_smile: