I wanted to use the latest langchain version and found out that the nixpkgs release 23.05 has langchain version 0.0.170. I verified this as following
$ nix repl
> :l <nixpkgs>
> pkgs.python3Packages.langchain.version
"0.0.170"
Looking at nixpkgs repo on GitHub, I found out that langchain version 0.0.268 is available in master branch.
In an attempt to see how I could use the latest available version in master, I found this on the wiki: User:Raboof - NixOS Wiki (I came across channels as well but this approach looked simpler)
I tried following this approach by setting up a worktree named nixpkgs-langchain
and using a simple Nix expression but it doesn’t seem to work. Here’s the expression:
# default.nix
{ pkgs ? import <nixpkgs> {} }:
let
customPkgs = import ~/Source/nixpkgs-langchain {
config.allowUnfree = true;
};
langchain = customPkgs.python3Packages.langchain;
# langchain = pkgs.python311Packages.buildPythonPackage customPkgs.python311Packages.langchain; # I tried this as well, didn't make any difference
my-python-packages = ps: with ps; [
langchain
];
my-python = pkgs.python3.withPackages my-python-packages;
in my-python.env
When I run nix-shell
, enter the Python repl and try to import langchain, I get ModuleNotFoundError: No module named 'langchain'
.
If I use nix repl
, I can see that the path is indeed correct:
$ nix repl
> let x = import ~/Source/nixpkgs-langchain {}; in x.python3Packages.langchain.version
"0.0.268"
I would appreciate any guidance as to what I’m doing wrong. Thanks.