Sign inGet started
← Back to all guides

Use Poetry in Deepnote instead of dealing with local packages

By Filip Žitný

Updated on July 9, 2024

Are you having trouble installing local packages in Deepnote? We got you covered.

Poetry is a robust dependency manager for Python projects, simplifying the management of dependencies and virtual environments. Unlike traditional package managers, it ensures consistency across different environments, maintaining a stable development workflow.

We will guide you through the steps of installing local packages in a Deepnote virtual environment. This process may seem daunting, but with our help, you will be able to navigate it with ease.

File tree

├── app
│   └── main.ipynb
├── poetry.lock
├── pyproject.toml
├── mypackage
│   ├── module1.py
│   └── module2.py
├── init.ipynb
└── .deepnote

Outline your Pyproject.toml accurately

Your pyproject.toml must contain your local package like so:

[tool.poetry]
name = "MyPackage
version = "0.1.0"
packages = [
{ include = "mypackage" },
]

[tool.poetry.dependencies]
python = "~3.9"
statsmodels = "^0.13.0"
ipykernel = { version = "^6.4.2", optional = true }
PuLP = "^2.5.1"

[tool.poetry.extras]
notebook = ["ipykernel"]

[build-system]
requires = ["poetry-core>=1.0.0"]
build-backend = "poetry.core.masonry.api"

Let Poetry handle your dependencies

Use the command poetry install to install your dependencies.

Configure Deepnote's environment variable

Fine-tune Deepnote's environment variable, PYTHONPATH, to locate your package:

Install local package.png
  1. In Deepnote, proceed to your project settings.
  2. Under environment variables, add a new variable with the name PYTHONPATH and value /work.

Confirm the Installation

Open your Jupyter notebook (e.g., ./app/main.ipynb) and attempt to import your package:

import mypackage

If everything is set up correctly, you should be able to import and use your package without issues.

Remember, following these simple steps will allow you to easily install and use your local packages in a Deepnote virtual environment, enhancing your productivity and innovation.

If you encounter further issues, please get in touch with our support. Happy hacking in Deepnote!

Filip Žitný

Data Scientist

Follow Filip on Twitter, LinkedIn and GitHub

That’s it, time to try Deepnote

Get started – it’s free
Book a demo

Footer

Solutions

  • Notebook
  • Data apps
  • Machine learning
  • Data teams

Product

Company

Comparisons

Resources

  • Privacy
  • Terms

© Deepnote