Skip to main content

nbreqs

nbreqs is a lightweight Python tool designed to extract the external library dependencies from Jupyter notebooks.

I made this tool because I manage repositories containing several notebooks with poetry, whereas users will only use single notebooks and copy them to other directories not themselves managed by poetry. They thus need requirement files specific to each notebook instead of the repository's total requirements.

nbreqs generates a <notebook>_requirements.txt file for each notebook in the same directory as each notebook.

Features

  • Finds notebooks recursively starting at the provided PATH.
  • Extracts only external dependencies found on PyPI (ignores standard library modules and sources other than PyPI).
  • Works on Jupyter notebooks.
  • Generates minimal <notebook>_requirements.txt files (one per notebook).

Installation

The preferred way of installing this tool is through pipx:

pipx install nbreqs

It can also be installed as a library through pip; check the tests for examples.

Usage

Once installed, the utility is used on the command line; see --help for details:

asciicast

The --pin option was removed in version 0.2.2. See issue #7 for details.

Starting with version 0.2.3, PATH can be either a filename or a directory.

Development

Contributions are welcome; please:

  • Activate pre-commit and use black.
  • Ensure pytest runs without failures.
  • Be nice.

License

nbreqs is licensed under the MIT License. See LICENSE file for details.

Metadata

Release files for nbreqs 0.2.3

For a detailed explanation of source distributions (sdists) and built distributions (wheels), please see the package formats documentation.

Built distribution (wheel)

Table of built distributions (wheels) for nbreqs 0.2.3
File Interpreter ABI Platform
nbreqs-0.2.3-py3-none-any.whl Python 3 none any Details

Release files / nbreqs-0.2.3-py3-none-any.whl

Download URL nbreqs-0.2.3-py3-none-any.whl
Size 4.6 kB
Tags Python 3
SHA-256 checksum
How to use checksums
43be746b8a6feda85ba7eb48ca494d2fc7102e55386e0bba258609c2fce6444b
BLAKE2b-256 checksum
How to use checksums
05a47a9485b7a4374355bfc74edcdf35a90540082e965342e3bce56c8899f9c0
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via twine/5.1.1 CPython/3.12.6

Release history Release notifications | RSS feed

This release

0.2.3 This release

1 release file

0.2.2

2 release files

0.2.1

2 release files

0.2.0

2 release files

0.1.4

2 release files

0.1.3

2 release files

0.1.2

2 release files

0.1.1

2 release files

0.1.0

2 release files

Anthropic, PBC Visionary sponsor Bloomberg Visionary sponsor Hudson River Trading Visionary sponsor Meta Visionary sponsor NVIDIA Visionary sponsor Microsoft Sustainability sponsor Depot Continuous Integration AWS Cloud computing and Security Sponsor Datadog Monitoring Fastly CDN Google Download Analytics Sentry Error logging StatusPage Status page