Nixos: how to install deps in jupyter notebook?

I’m trying to install Jupyter notebook on NixOs, but I can’t find how to install numpy, and other libraries into jupyter. For now I added in my configuration.nix something like:

{ config, pkgs, ... }:
  python3-with-my-packages =
    pkgs.python3.withPackages (python-packages: with python-packages; [
  environment.systemPackages = with pkgs; [

Unix & Linux Asked on November 21, 2021

4 Answers

4 Answers

There a great write up here of using Juypter with Nixos.

Answered by The Unix Janitor on November 21, 2021

You may also want to take a look at the topic Jupyter notebook with batteries in NixOS Discourse for some discussion on the Nixy dependency management for Jupyter Notebook.

If you want something compatible with non-Nix environment, I just managed to find a way to use Poetry inside NixOS with the help of mkPoetryEnv and buildFHSUserEnv:

Just place two files in the top-level directory of the Poetry project:


{pkgs ? import <nixpkgs> {} }:
  lib = pkgs.lib;
  poetry2nix = pkgs.poetry2nix;
  python37 = pkgs.python37;
  poetry2nix.mkPoetryEnv {
    python = python37;
    pyproject = ./pyproject.toml;
    poetrylock = ./poetry.lock;


  pkgs ? import <nixpkgs> {},
  # This allows us to provide a command to run via `--argstr run COMMAND`.
  run ? "bash"
  poetry-env = import ./poetry-env.nix { };
  with pkgs; (buildFHSUserEnv {
    name = "poetry-env-fhs";
    targetPkgs = pkgs: with pkgs; [
      # curl
      # git
      pandoc # for pdf conversion
      texlive.combined.scheme-full # for pdf conversion
      which # a convenient tool in vertualized environments
    ] ++ [
    runScript = "${run}";
    profile = ''
      # export SSL_CERT_FILE=${cacert}/etc/ssl/certs/ca-bundle.crt
      # export GIT_SSL_CAINFO="$SSL_CERT_FILE"
      # export LANG=C.UTF-8

Since it takes quite a while for mkPoetryEnv to build a package, you may want to nix-build ./poetry-env.nix to keep the build result from being GC-ed.

Jupyter notebook dependency management with Poetry

Answered by Shamrock Lee on November 21, 2021

A small shell.nix file for a Jupyter Notebook could look like the following.

with import <nixpkgs> {};

(pkgs.python3.withPackages (ps: with ps; [
    ipykernel jupyterlab
    matplotlib numpy pandas seaborn

To start, copy a modified version of the shell.nix file to your project directory and run nix-shell --run "jupyter lab".

Answered by Gumoringer on November 21, 2021

I'm not claiming this is the best solution, but it seems that the jupyter package is not the one we need, but instead we just want to add the python package notebook to the list of deps:

{ config, pkgs, ... }:
  python3-with-my-packages =
    pkgs.python3.withPackages (python-packages: with python-packages; [
  environment.systemPackages = with pkgs; [

Let me know if it's not the way to go and if there is a better solution!

Answered by tobiasBora on November 21, 2021

Add your own answers!

Related Questions

PulseAudio module-remap-source blocks shutdown

0  Asked on February 2, 2021 by konrad-hffner


Gedit doesn’t work in Kali 2020

0  Asked on February 1, 2021 by mate-mre


Trying to Install Linux Alongside Windows 10

2  Asked on January 30, 2021 by jackson-a-cubbage


EasyTether Internet Disconnect on OpenWRT Router

0  Asked on January 30, 2021 by jack-nelson


Issues installing Nvidia drivers in Debian 9

1  Asked on January 29, 2021 by axiomsword


Sorting by date with format dd-Mmm-yyyy from specific file

3  Asked on January 29, 2021 by jugarugabi


Why do Unix/Linux systems still need to depend on Microsoft?

1  Asked on January 29, 2021 by ray-butterworth


Pass Key value as Paramenter

0  Asked on January 29, 2021 by sivaguru


Apache vhost local request

2  Asked on January 29, 2021 by rumburak


Ask a Question

Get help from others!

© 2021 All rights reserved.