DavHau / mach-nix

Create highly reproducible python environments
MIT License
869 stars 106 forks source link

How to use the mach-nix derivativ in jupyterWith? #86

Closed InLaw closed 4 years ago

InLaw commented 4 years ago

How to use the mach-nix derivativ in jupyterWith? jupyterWith

DavHau commented 4 years ago

Is this still relevant given the examples for jupyterLab we have added? https://github.com/DavHau/mach-nix/blob/master/examples.md#jupyterlab

InLaw commented 4 years ago

would be nice to get the nix ecosystem working together and being interoperable tooling but jupyterWith doesn't seem to have interest in that .. for now

InLaw commented 4 years ago
let
    mach-nix = import (builtins.fetchGit {
      url = "https://github.com/DavHau/mach-nix/";
      ref = "refs/tags/3.0.2";
    }) {
      python = "python37";
    };
in
let
  machNix = mach-nix.mkPython rec {
    requirements = ''
      pillow
      numpy
      requests
      pandas
      seaborn

      scikit-learn

      TPOT
      shap

      geopandas
      geoplot
      mapclassify

      Shapely

      rpy2

    '';
  };

  # Standard JupyterWith boilerplate.
  jupyter = import (builtins.fetchGit {
    url = https://github.com/tweag/jupyterWith;
    rev = "48bd88ac0acb4aaa841debe5fb201c297f374101";
  }) {};

  iPython = jupyter.kernels.iPythonWith {
    name = "NixPy";
    # You want to use a package from another source, so you can ignore the p parameter.
    python3 = machNix.python;
    packages = machNix.python.pkgs.selectPkgs;
  };

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

Traceback (most recent call last):
  File "/nix/store/cpzs1hpwzs23c41haa4dap0zjfx6xych-python3-3.7.9/lib/python3.7/runpy.py", line 193, in _run_module_as_main
    "__main__", mod_spec)
  File "/nix/store/cpzs1hpwzs23c41haa4dap0zjfx6xych-python3-3.7.9/lib/python3.7/runpy.py", line 85, in _run_code
    exec(code, run_globals)
  File "/nix/store/h5pp34jbs854h3c5xfxxssj54as85y7r-python3.7-ipykernel-5.2.1/lib/python3.7/site-packages/ipykernel_launcher.py", line 15, in <module>
    from ipykernel import kernelapp as app
  File "/nix/store/h5pp34jbs854h3c5xfxxssj54as85y7r-python3.7-ipykernel-5.2.1/lib/python3.7/site-packages/ipykernel/__init__.py", line 2, in <module>
    from .connect import *
  File "/nix/store/h5pp34jbs854h3c5xfxxssj54as85y7r-python3.7-ipykernel-5.2.1/lib/python3.7/site-packages/ipykernel/connect.py", line 18, in <module>
    import jupyter_client
  File "/nix/store/apgs7ngbhgwiw34sjr38q6498m7hv07h-python3.7-jupyter_client-6.1.3/lib/python3.7/site-packages/jupyter_client/__init__.py", line 4, in <module>
    from .connect import *
  File "/nix/store/apgs7ngbhgwiw34sjr38q6498m7hv07h-python3.7-jupyter_client-6.1.3/lib/python3.7/site-packages/jupyter_client/connect.py", line 21, in <module>
    import zmq
  File "/nix/store/7780y6dm8hjpqysyqf6iq7gfkl7ky69a-python3.7-pyzmq-18.1.1/lib/python3.7/site-packages/zmq/__init__.py", line 47, in <module>
    from zmq import backend
  File "/nix/store/7780y6dm8hjpqysyqf6iq7gfkl7ky69a-python3.7-pyzmq-18.1.1/lib/python3.7/site-packages/zmq/backend/__init__.py", line 40, in <module>
    reraise(*exc_info)
  File "/nix/store/7780y6dm8hjpqysyqf6iq7gfkl7ky69a-python3.7-pyzmq-18.1.1/lib/python3.7/site-packages/zmq/utils/sixcerpt.py", line 34, in reraise
    raise value
  File "/nix/store/7780y6dm8hjpqysyqf6iq7gfkl7ky69a-python3.7-pyzmq-18.1.1/lib/python3.7/site-packages/zmq/backend/__init__.py", line 27, in <module>
    _ns = select_backend(first)
  File "/nix/store/7780y6dm8hjpqysyqf6iq7gfkl7ky69a-python3.7-pyzmq-18.1.1/lib/python3.7/site-packages/zmq/backend/select.py", line 28, in select_backend
    mod = __import__(name, fromlist=public_api)
  File "/nix/store/7780y6dm8hjpqysyqf6iq7gfkl7ky69a-python3.7-pyzmq-18.1.1/lib/python3.7/site-packages/zmq/backend/cython/__init__.py", line 6, in <module>
    from . import (constants, error, message, context,
ImportError: /nix/store/nwsn18fysga1n5s0bj4jp4wfwvlbx8b1-glibc-2.30/lib/librt.so.1: undefined symbol: __clock_nanosleep, version GLIBC_PRIVATE