{"id":16519742,"url":"https://github.com/zonca/nbenv","last_synced_at":"2025-08-24T16:45:31.181Z","repository":{"id":46084605,"uuid":"105763775","full_name":"zonca/nbenv","owner":"zonca","description":null,"archived":false,"fork":false,"pushed_at":"2022-12-26T20:26:03.000Z","size":38,"stargazers_count":5,"open_issues_count":4,"forks_count":2,"subscribers_count":3,"default_branch":"master","last_synced_at":"2025-02-01T12:45:29.954Z","etag":null,"topics":[],"latest_commit_sha":null,"homepage":null,"language":"Python","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":"mit","status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/zonca.png","metadata":{"files":{"readme":"README.rst","changelog":null,"contributing":"docs/contributing.rst","funding":null,"license":"LICENSE","code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null}},"created_at":"2017-10-04T12:08:18.000Z","updated_at":"2018-04-04T02:56:13.000Z","dependencies_parsed_at":"2023-01-31T01:15:46.527Z","dependency_job_id":null,"html_url":"https://github.com/zonca/nbenv","commit_stats":null,"previous_names":[],"tags_count":5,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/zonca%2Fnbenv","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/zonca%2Fnbenv/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/zonca%2Fnbenv/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/zonca%2Fnbenv/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/zonca","download_url":"https://codeload.github.com/zonca/nbenv/tar.gz/refs/heads/master","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":238614524,"owners_count":19501476,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2022-07-04T15:15:14.044Z","host_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub","repositories_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories","repository_names_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repository_names","owners_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners"}},"keywords":[],"created_at":"2024-10-11T16:48:09.824Z","updated_at":"2025-02-13T07:31:08.851Z","avatar_url":"https://github.com/zonca.png","language":"Python","funding_links":[],"categories":[],"sub_categories":[],"readme":"=====\nnbenv\n=====\n\n\n.. image:: https://img.shields.io/pypi/v/nbenv.svg\n        :target: https://pypi.python.org/pypi/nbenv\n\n.. image:: https://img.shields.io/travis/zonca/nbenv.svg\n        :target: https://travis-ci.org/zonca/nbenv\n\nStore conda environment package list inside Notebook documents\n\nThis package provides a hook for the Jupyter Notebook that saves metadata about the\nconda environment (equivalent of `conda env export`) inside the Notebook `.ipynb` file\neverytime that the Notebook is saved.\nIt also supports packages installed inside the conda environment with `pip`.\n\nOnce such Jupyter Notebook is shared, another user can inspect the environment where\nit ran:\n\n.. code-block:: bash\n\n    $ nbenv --extract my_notebook.ipynb\n\n    name: test_input_env\n    channels:\n    - defaults\n    - conda-forge\n    dependencies:\n    - ca-certificates=2017.08.26=h1d4fec5_0\n    - certifi=2017.7.27.1=py35h19f42a1_0\n    - decorator=4.1.2=py35h3a268aa_0\n    - ipykernel=4.6.1=py35h29d130c_0\n    - ipython=6.1.0=py35h1b71439_1\n    - ipython_genutils=0.2.0=py35hc9e07d0_0\n    - jupyter_client=5.1.0=py35h2bff583_0\n    - pip:\n      - ipython-genutils==0.2.0\n      - jupyter-client==5.1.0\n\nAnd re-create the same environment (includes install of IPython Kernel):\n\n.. code-block:: bash\n\n    $ nbenv my_notebook.ipynb --name reconstructed_env\n    $ source activate reconstructed_env\n    $ jupyter notebook\n\nThe environment metadata will be preserved if the Notebook file is modified by a Jupyter Notebook session\nwith no ``nbenv`` installed.\n\nInstall\n--------\n\nInstall the package with `pip install nbenv`\n\nInstall the Jupyter Notebook hook in your `.jupyter/jupyter_notebook_config.py`:\n\n.. code-block:: python\n\n    try:\n        from nbenv import save_conda_environment\n        c.FileContentsManager.pre_save_hook = save_conda_environment\n    except ImportError:\n        print(\"nbenv package not found: automatic saving of conda environment disabled\")\n\nImplementation details\n----------------------\n\nThe `pre_save_hook` is automatically triggered by the Jupyter Notebook before saving the Notebook\nto disk.\nIt identifies the conda environment being run checking the KernelSpec and then calls ``conda env export``\nand saves the output in ``[\"content\"][\"metadata\"][\"conda_environment\"]`` in the ``.ipynb`` JSON.\n\nThe ``nbenv`` command line tool can then extract that and use ``conda create`` to a new environment.\n\nCredits\n---------\n\nDesign of this package was conceived during discussion at the `Container Analysis Environments Workshop`_\nheld at NCSA in August 2017.\n\n.. _`Container Analysis Environments Workshop`: https://nationaldataservice.atlassian.net/wiki/spaces/NDSC/pages/37284774/Container+Analysis+Environments+Workshop\n\nThis package was created with Cookiecutter_ and the `audreyr/cookiecutter-pypackage`_ project template.\n\n.. _Cookiecutter: https://github.com/audreyr/cookiecutter\n.. _`audreyr/cookiecutter-pypackage`: https://github.com/audreyr/cookiecutter-pypackage\n\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fzonca%2Fnbenv","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fzonca%2Fnbenv","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fzonca%2Fnbenv/lists"}