{"id":1982,"date":"2025-08-23T23:23:28","date_gmt":"2025-08-23T11:23:28","guid":{"rendered":"https:\/\/www.ronella.xyz\/?p=1982"},"modified":"2025-08-23T23:23:28","modified_gmt":"2025-08-23T11:23:28","slug":"how-to-use-jupyter-notebook-with-poetry-a-step-by-step-guide","status":"publish","type":"post","link":"https:\/\/www.ronella.xyz\/?p=1982","title":{"rendered":"How to Use Jupyter Notebook with Poetry: A Step-by-Step Guide"},"content":{"rendered":"<p>Poetry is a powerful dependency management and packaging tool for Python projects, offering isolated virtual environments and reproducible builds. Using Jupyter Notebook with Poetry allows you to work seamlessly within the same environment managed by Poetry, ensuring all your dependencies are consistent.<\/p>\n<p>This guide will take you through the steps to get up and running with Jupyter Notebook using Poetry.<\/p>\n<hr \/>\n<h2>Step 1: Install Poetry Using pip<\/h2>\n<p>You can install Poetry using pip, the Python package installer. Run the following command:<\/p>\n<pre><code class=\"language-shell\">pip install poetry<\/code><\/pre>\n<p>After installation, verify that Poetry is installed and accessible:<\/p>\n<pre><code class=\"language-shell\">poetry --version<\/code><\/pre>\n<hr \/>\n<h2>Step 2: Create a New Poetry Project<\/h2>\n<p>Create a new directory for your project and initialize it with Poetry:<\/p>\n<pre><code class=\"language-shell\">mkdir my-jupyter-project\ncd my-jupyter-project\npoetry init --no-interaction<\/code><\/pre>\n<p>This generates a <code>pyproject.toml<\/code> file to manage your project\u2019s dependencies.<\/p>\n<hr \/>\n<h2>Step 3: Add Jupyter and ipykernel as Dependencies<\/h2>\n<p>Add Jupyter Notebook as a development dependency:<\/p>\n<pre><code class=\"language-shell\">poetry add --dev jupyter ipykernel<\/code><\/pre>\n<p>You can also add other libraries you plan to use (e.g., pandas, numpy):<\/p>\n<pre><code class=\"language-shell\">poetry add pandas numpy<\/code><\/pre>\n<hr \/>\n<h2>Step 4: Install the Jupyter Kernel for Your Poetry Environment<\/h2>\n<p>Make your Poetry virtual environment available as a kernel in Jupyter so you can select it when you launch notebooks:<\/p>\n<pre><code class=\"language-shell\">poetry run python -m ipykernel install --user --name=my-jupyter-project<\/code><\/pre>\n<p>Replace <code>my-jupyter-project<\/code> with a meaningful name for your kernel.<\/p>\n<hr \/>\n<h2>Step 5: Launch Jupyter Notebook<\/h2>\n<p>Run Jupyter Notebook using Poetry to ensure you are using the correct virtual environment:<\/p>\n<pre><code class=\"language-shell\">poetry run jupyter notebook<\/code><\/pre>\n<p>This command will start Jupyter Notebook in your browser. When you create or open a notebook, make sure to select the kernel named after your Poetry environment (<code>my-jupyter-project<\/code> in this example).<\/p>\n<hr \/>\n<h2>Step 6: Start Coding!<\/h2>\n<p>You now have a fully isolated environment managed by Poetry, using Jupyter Notebook for your interactive computing. All the dependencies installed via Poetry are ready to use.<\/p>\n<hr \/>\n<h2>Optional: Using Jupyter Lab<\/h2>\n<p>If you prefer Jupyter Lab, you can add and run it similarly:<\/p>\n<pre><code class=\"language-shell\">poetry add --dev jupyterlab\npoetry run jupyter lab<\/code><\/pre>\n<hr \/>\n<p>This method ensures your Jupyter notebooks are reproducible, isolated, and aligned with your Poetry-managed Python environment, improving project consistency and collaboration.<\/p>\n<p>If you use VSCode, be sure to select the Poetry virtual environment interpreter and the corresponding Jupyter kernel to have a smoother development experience.<\/p>\n<p>Enjoy coding with Poetry and Jupyter!<\/p>\n","protected":false},"excerpt":{"rendered":"<p>Poetry is a powerful dependency management and packaging tool for Python projects, offering isolated virtual environments and reproducible builds. Using Jupyter Notebook with Poetry allows you to work seamlessly within the same environment managed by Poetry, ensuring all your dependencies are consistent. This guide will take you through the steps to get up and running [&hellip;]<\/p>\n","protected":false},"author":1,"featured_media":0,"comment_status":"open","ping_status":"open","sticky":false,"template":"","format":"standard","meta":[],"categories":[88],"tags":[],"_links":{"self":[{"href":"https:\/\/www.ronella.xyz\/index.php?rest_route=\/wp\/v2\/posts\/1982"}],"collection":[{"href":"https:\/\/www.ronella.xyz\/index.php?rest_route=\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/www.ronella.xyz\/index.php?rest_route=\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/www.ronella.xyz\/index.php?rest_route=\/wp\/v2\/users\/1"}],"replies":[{"embeddable":true,"href":"https:\/\/www.ronella.xyz\/index.php?rest_route=%2Fwp%2Fv2%2Fcomments&post=1982"}],"version-history":[{"count":1,"href":"https:\/\/www.ronella.xyz\/index.php?rest_route=\/wp\/v2\/posts\/1982\/revisions"}],"predecessor-version":[{"id":1983,"href":"https:\/\/www.ronella.xyz\/index.php?rest_route=\/wp\/v2\/posts\/1982\/revisions\/1983"}],"wp:attachment":[{"href":"https:\/\/www.ronella.xyz\/index.php?rest_route=%2Fwp%2Fv2%2Fmedia&parent=1982"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/www.ronella.xyz\/index.php?rest_route=%2Fwp%2Fv2%2Fcategories&post=1982"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/www.ronella.xyz\/index.php?rest_route=%2Fwp%2Fv2%2Ftags&post=1982"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}