Poetry Kernel
Use per-directory Poetry environments to run Jupyter kernels. No need to install a Jupyter kernel per Python virtual environment!
The idea behind this project is to allow you to capture the exact state of your environment. This means you can email your work to your peers, and they'll have exactly the same set of packages that you do! Reproducibility!
Why not virtual environments (venvs)?
Virtual environments were (and are) an important advancement to Python's package management story, but they have a few shortcomings:
- They are not great for reproducibility. Usually, you'll create a new virtual
environment using a
requirements.txtwhich includes all the direct dependencies (numpy, pandas, etc.), but not transient dependencies (pandas depends on pytz for timezone support, for example). And usually, even the direct dependencies are specified only as minimum (or semver) ranges (e.g.,numpy>=1.21) which can make it hard or impossible to accurately recreate thevenvlater. - With Jupyter, they usually require that the kernels be installed globally. This means you'll need need to have a separate kernelspec for every venv you want to use with Jupyter.
Poetry uses venvs transparently under the hood by constructing them from the
pyproject.toml and poetry.lock files. The poetry.lock file records the
exact state of dependencies (and transient dependencies) and can be used to more
accurately reproduce the environment.
Additionally, Poetry Kernel means you only have to install one kernelspec. It
then uses the pyproject.toml file from the directory of the notebook (or any
parent directory) to choose which environment to run the notebook in.
Shameless plug
The reason we created this package was to make sure that the code environments created for running student code on Pathbird exactly match your development environment. Interested in developing interactive, engaging, inquiry-based lessons for your students? Check out Pathbird for more information!
Usage
- Install Poetry if not yet installed.
- Install this package:
# NOTE: Do **NOT** install this package in your Poetry project, it should be # installed at the system or user level. pip3 install --user poetry-kernel
- Initialize a Poetry project (only required if you do not have an existing
Poetry project ready to use):
poetry init -n
- IMPORTANT: Add
ipykernelto your project's dependencies:# In the directory of your Poetry project poetry add ipykernel
- Start a "Poetry" Jupyter kernel and see it in action!
Troubleshooting
Kernel isn't starting ("No Kernel" message)
Pro-tip: Check the output of the terminal window where you launched Jupyter. It will usually explain why the kernel is failing to start.
- Make sure that you are launching a notebook in a directory/folder that
contains a Poetry project (
pyproject.tomlandpoetry.lockfiles). You can turn a directory into a Poetry project by running:
poetry init -n
- Make sure that you've installed
ipykernelinto your project:
poetry add ipykernel
-
Make sure the Poetry project is installed! This is especially important for projects that you have downloaded from others (warning: installing a Poetry project could run arbitrary code on your computer, make sure you trust your download first!):
poetry install -
Still can't figure it out? Open an issue!
A package I added won't import properly
If you added the package after starting the kernel, you might need to restart the kernel for it to see the new package.
FAQ
Metadata
Release files for poetry-kernel 0.1.3
For a detailed explanation of source distributions (sdists) and built distributions (wheels), please see the package formats documentation.
Source distribution (sdist)
| File | Size | Uploaded | Provenance | Actions |
|---|---|---|---|---|
| poetry-kernel-0.1.3.tar.gz | 5.6 kB | Without provenance | Details for poetry-kernel-0.1.3.tar.gz |
Built distribution (wheel)
| File | Interpreter | ABI | Platform | Actions Reset |
|---|---|---|---|---|
| poetry_kernel-0.1.3-py3-none-any.whl | Python 3 | none | any | Details for poetry_kernel-0.1.3-py3-none-any.whl |
Total release size: 11.5 kB
Release files / poetry-kernel-0.1.3.tar.gz
| Download URL | poetry-kernel-0.1.3.tar.gz |
|---|---|
| Size | 5.6 kB |
| Tags | Source |
|
SHA-256 checksum How to use checksums |
a586631fca31185dbb5f4b8e88a8a30b00bf857b6bc5935b277cfe4f48e90f27
|
|
BLAKE2b-256 checksum How to use checksums |
be4d5ad6340a3c1ffaccb1d58067a6af079eed2d4190a80ebab2d1f2b543f14d
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
No |
| Uploaded via |
twine/4.0.2 CPython/3.11.4
|
Release files / poetry_kernel-0.1.3-py3-none-any.whl
| Download URL | poetry_kernel-0.1.3-py3-none-any.whl |
|---|---|
| Size | 6.0 kB |
| Tags | Python 3 |
|
SHA-256 checksum How to use checksums |
1722d057a716d7bfc4cc763809e5f5cd5c859c8767ecffc67a5e017768fa9caa
|
|
BLAKE2b-256 checksum How to use checksums |
af273c03d7ae193f089ca0232fd11a2bda119bc2c4f68675fa6ecd8503161360
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
No |
| Uploaded via |
twine/4.0.2 CPython/3.11.4
|
Security for poetry-kernel 0.1.3
Provenance
Provenance describes where a file came from. On PyPI, provenance is shared via attestations, which provide a verifiable record of the build or publishing details. View details, limitations and caveats.
No provenance found
None of the files in this release were uploaded with provenance metadata.
A note on package security
PyPI is a repository for distributing packages, not a service for auditing them. While third-party security researchers and our staff do their best to detect and remove malicious packages, PyPI cannot guarantee the quality, security or suitability of any given package.
To learn more about protecting yourself from malicious actors, visit our package security documentation.