Running jupyter notebook installed inside a virtualenv

I have setup my Python project using virtualenv using python.poetry package. Not yet moved to nix-shell. the installation of all packages went without any errors. But I am not able to run jupyter notebook.

I was getting some errors related to czmq. I have installed the pacakge globally with environment.systemPackages. After I am getting the following error

I haven’t done systems programming and don’t know much about LD_LIBRARY_PATH. I have checked other posts that told to set the LD_LIBRARYPATH. But that doesn’t work for me.

Could anyone help me get it setup and running ?

1 Like

I’ve just find a way to run Jupyter Notebook managed by Poetry in NixOS.
Create the environment package first with mkPoetryEnv and then send it to buildFHSUserEnv.

Here is what I do:

The two pieces of code are borrowed from other people (one from this forum and and another from the poetry2nix documentation) with a few modifications, as I’m also a newbie here.

BTW, it seems better to categorize this topic as #learn instead of howto.

1 Like

you can follow my post from Jupyter notebook dependency management with Poetry . You will want nixpkgs to supply you with a version of pyzmq which has been linked against

Your underlying issue is that nixos only exposes the libc libraries, but not the c++ libraries, which is why some .so’s will work fine, but many c++ ones will not.

I also made a video demonstrating nix python package usage with nix-shell here: . I fast forwarded to roughly the correct spot.


Thanks very much I will check it out. Is there anyway to set these variables correctly without nix-shell ?

like we used to in other distros. Also that way the IDEs will be working with notebooks without having to start from commandline .

if all of your dependencies are in nixpkgs, you could use python.withPackages, and build a ipykernel which references it. Poetry2nix will probably allow you to do similar things, I just don’t have any experience with it.

1 Like

You may also be interested in mach-nix
I haven’t tested it yet, but it sounds interesding.