jupyenv icon indicating copy to clipboard operation
jupyenv copied to clipboard

Modules not accessible inside nix-shell environment created by jupyterWith

Open rowhit opened this issue 4 years ago • 0 comments

I am using the following simple shell.nix file, close to the one given in the documentation:

{ pkgs ? import <nixpkgs> {} }:

let
  jupyter = import (builtins.fetchGit {
    url = https://github.com/tweag/jupyterWith;
    rev = "";
  }) {};

  iPython = jupyter.kernels.iPythonWith {
    name = "python";
    packages = p: with p; [ ipython numpy pandas ];
  };

  jupyterEnvironment =
    jupyter.jupyterlabWith {
      kernels = [ iPython ];
      directory = ./jupyterlab;
    };
in
  jupyterEnvironment.env

Once I enter the nix shell I can access ipython shell but cannot call numpy and pandas modules defined in the package section. The pandas and numpy are not there in the $PYTHONPATH. Do I need specify anything else in the shell.nix file? Here is the output:

Python 3.7.7 (default, Mar 10 2020, 06:34:06) 
Type 'copyright', 'credits' or 'license' for more information
IPython 7.13.0 -- An enhanced Interactive Python. Type '?' for help.

In [1]: import pandas as pd                
---------------------------------------------------------------------------
ModuleNotFoundError                       Traceback (most recent call last)
<ipython-input-1-7dd3504c366f> in <module>
----> 1 import pandas as pd

ModuleNotFoundError: No module named 'pandas'

In [2]:    

I am running this on Ubuntu 20.04 with nipxkgs-unstable channel ("https://nixos.org/channels/nixpkgs-unstable").

Also, how do I:

  • Define python packages that are not in the nixpkgs repo using mach-nix?
  • Change the python version to the latest?

rowhit avatar Dec 11 '20 22:12 rowhit