I want to have some packages installed with virtualenv (custom packages) and some I would like to have automatically installed, eg in withPackages. How can I obtain this? If I install numpy using pip install numpy
, and then run python
, I am able to import numpy
, but not import torch
. How can I fix this:
flake.nix:
{
description = "A Python project with NumPy";
inputs = {
nixpkgs.url = "github:nixos/nixpkgs/nixos-22.11";
};
outputs = { self, nixpkgs }:
let
system = "x86_64-linux";
pkgs = nixpkgs.legacyPackages.${system};
pyEnv = pkgs.python3.withPackages (ps: with ps; [
torch
virtualenv
]);
buildInputs = with pkgs; [
pyEnv
zlib
];
in
{
devShell.${system} = pkgs.mkShell {
buildInputs = buildInputs;
shellHook = ''
export LD_LIBRARY_PATH="${pkgs.lib.makeLibraryPath buildInputs}:$LD_LIBRARY_PATH"
export LD_LIBRARY_PATH="${pkgs.stdenv.cc.cc.lib.outPath}/lib:$LD_LIBRARY_PATH"
source venv/bin/activate
'';
};
};
}