Tensorflow in Haskell

I set up my haskell project with cabal2nix following this guide (https://github.com/Gabriel439/haskell-nix/blob/master/project1/README.md).
My cabal file looks like this

cabal-version:       >=1.10
-- Initial package description 'tensorFlowCabal.cabal' generated by 'cabal
-- init'.  For further documentation, see
-- http://haskell.org/cabal/users-guide/

name:                tensorFlowCabal
version:             0.1.0.0
-- synopsis:
-- description:
-- bug-reports:
-- license:
license-file:        LICENSE
author:              felix
maintainer:          felix@aipieper
-- copyright:
-- category:
build-type:          Simple
extra-source-files:  CHANGELOG.md

executable tensorFlowCabal
  main-is:             Main.hs
  -- other-modules:
  -- other-extensions:
  build-depends:       base >=4.12 && <4.13,
		       tensorflow
  -- hs-source-dirs:
  default-language:    Haskell2010

my release.nix looks like this

let 
config = {
  allowBroken = true;
  packageOverrides = pkgs: rec {
      haskellPackages = pkgs.haskellPackages.override {
        overrides = haskellPackagesNew: haskellPackagesOld: rec {
          project =
            haskellPackagesNew.callPackage ./tensorFlowCabal.nix { };
        };
      };
    };
  };
  pkgs = import <nixpkgs> { inherit config; };

in 
  {  tensorFlowCabal = pkgs.haskellPackages.project;
  }

when I try to run nix-build i just get the error:

error: tensorflow-1.15.2 not supported for interpreter python2.7
(use '--show-trace' to show detailed location information)

I don’t really understand it because in my global nix config is python 3.7.6 defined. Most likely did I do a horrible mistake, I am new to nix. I would like to use tensorflow in haskell, but I can’t get it working. Any help is appreciated.

Your “global” python is not relevant. Each project uses what is defined within the project.

Perhaps show your tensorflow.nix.

1 Like

somehow pythonPackages.tensorflow is being referenced. And it indeed, does not support python2

i previously had pythonPackages.tensorflow installed (but removed yesterday sometimes).
My tensorflowCabal.nix file looks like this

{ mkDerivation, base, stdenv, tensorflow }:
mkDerivation {
  pname = "tensorFlowCabal";
  version = "0.1.0.0";
  src = ./.;
  isLibrary = false;
  isExecutable = true;
  executableHaskellDepends = [ base tensorflow ];
  license = "unknown";
  hydraPlatforms = stdenv.lib.platforms.none;
}

I also Tried pinning the tensorflow package with cabal2nix cabal://tensorflow-0.2.0.1 > tensorflow.nix and added the package in the release file, but it still throws the Error:

error: tensorflow-1.15.2 not supported for interpreter python2.7
(use '--show-trace' to show detailed location information)

I can feel that i make a terrible mistake but i don’t see it…

I’m assuming the tensorflow here:

{ mkDerivation, base, stdenv, tensorflow }:

is referencing python2Packages.tensorflow

how is that being called?

you could try doing

  myPackage = callPackage ./my-package { tensorflow = python3Packages.tensorflow; };