在 NixOS 中,如何安装最新的 Jupyterlab?

在 NixOS 中,如何安装最新的 Jupyterlab?

我尝试运行pypi2nix -V 3 -e jupyterlab==1.0.0,但失败并显示“无法构建 ipykernel”。

还有其他方法可以安装 1.0.X 版本的 jupyterlab 吗?

编辑:我越来越接近了。这是我正在运行的 jupyterlab.nix nix-shell jupyterlab.nix

with import <nixpkgs> {};

( let
    my_jupyterlab = python37.pkgs.buildPythonPackage rec {
      pname = "jupyterlab";
      version = "1.0.4";

      src = python37.pkgs.fetchPypi {
        inherit pname version;
        sha256 = "0vhdbzrphirl3x37d4zh0gaxhs6f7wj0i30wy4878yjkmlr219rj";
      };

      doCheck = false;
    };

  in python37.withPackages (ps: [ps.jupyter ps.tornado my_jupyterlab])
).env

但这无法建立,说明了龙卷风的情况。

答案1

在这里你可以找到一个合适的模板首先:

# default37.nix
# start with
#   nix-shell default37.nix
# or
#   nix-shell default37.nix -I nixpkgs=/home/isto/nixpkgs-unstable/
let 
  pkgs = import <nixpkgs> {};
  newpkgs = import pkgs.path { overlays = [ (pkgsself: pkgssuper: {
    python37 = let
      packageOverrides = self: super: {
            openpyxl = openpyxl2;
        # numpy = super.numpy_1_10;
      };
    in pkgssuper.python37.override {inherit packageOverrides;};
  } ) ]; };
  
  multitasking = newpkgs.callPackage /...../......./multitasking/default.nix {
    buildPythonPackage = newpkgs.python37Packages.buildPythonPackage;
    fetchPypi = newpkgs.python37Packages.fetchPypi;
  };
  openpyxl2 = pkgs.callPackage /..../...../openpyxl/default.nix {
    buildPythonPackage = pkgs.python37Packages.buildPythonPackage;
    fetchPypi = pkgs.python37Packages.fetchPypi;
    isPy27 = pkgs.python37Packages.isPy27;
    pytest = pkgs.python37Packages.pytest;
    jdcal = pkgs.python37Packages.jdcal;
    et_xmlfile = pkgs.python37Packages.et_xmlfile;
    lxml = pkgs.python37Packages.lxml;
  };
  yfinance = newpkgs.callPackage /..../...../yfinance/default.nix {
    buildPythonPackage = newpkgs.python37Packages.buildPythonPackage;
    fetchPypi = newpkgs.python37Packages.fetchPypi;
    pandas = newpkgs.python37Packages.pandas;
    numpy = newpkgs.python37Packages.numpy;
    requests = newpkgs.python37Packages.requests;
    multitasking = multitasking;
  };
  kernels = [
    # pkgs.python37Packages.ansible-kernel
    # pythonPackages.jupyter-c-kernel
    # pkgs.gophernotes
  ];
  additionalExtensions = [
    "@jupyter-widgets/jupyterlab-manager"
    "@bokeh/jupyter_bokeh"
    "@pyviz/jupyterlab_pyviz"
  ];
  pythonEnv = newpkgs.python37.withPackages (ps: with ps; [
    ipykernel jupyterlab jupyterlab_server
    python-language-server pyls-isort
    matplotlib numpy pandas scikitlearn
    tensorflow tensorflow-tensorboard 
    bokeh bkcharts networkx statsmodels seaborn
    holoviews hvplot 
    param pyviz-comms
    Keras keras-applications keras-preprocessing
    Theano 
    nltk
    scipy plotly
    sympy
    yfinance
    openpyxl
    #openpyxl2
    sphinx nbsphinx nbconvert
    dash dash-html-components dash-core-components dash-renderer dash-table
    jinja2 
    ipywidgets
  ]);
  
in newpkgs.mkShell rec {
  buildInputs = [
    pythonEnv
    pkgs.nodejs

  ] ++ kernels;
  shellHook = ''
    TEMPDIR=$(mktemp -d -p /tmp)
    mkdir -p $TEMPDIR
    cp -r ${pkgs.python37Packages.jupyterlab}/share/jupyter/lab/* $TEMPDIR
    chmod -R 755 $TEMPDIR
    echo "$TEMPDIR is the app directory"

    # kernels
    export JUPYTER_PATH="${pkgs.lib.concatMapStringsSep ":" (p: "${p}/share/jupyter/") kernels}"

# labextensions
${pkgs.stdenv.lib.concatMapStrings
     (s: "jupyter labextension install --no-build --app-dir=$TEMPDIR ${s}; ")
     (pkgs.lib.unique
       ((pkgs.lib.concatMap
           (d: pkgs.lib.attrByPath ["passthru" "jupyterlabExtensions"] [] d)
           buildInputs) ++ additionalExtensions))  }
jupyter lab build --app-dir=$TEMPDIR
chmod -R +w $TEMPDIR/staging/
jupyter lab build --app-dir=$TEMPDIR
 
# start jupyterlab
jupyter lab --app-dir=$TEMPDIR
    '';
}

相关内容