Sign inGet started
← Back to all guides

How to convert Jupyter to Python

By Nick Barth

Updated on March 6, 2024

Converting a Jupyter notebook to a Python script (.py file) can be an essential task when you're looking to deploy or automate a data analysis workflow that you have prototyped in Jupyter. If you are using Deepnote, an online notebook environment, this process is straightforward.

Below, you will find the steps to convert a Jupyter notebook into a Python script while working within Deepnote:

Step 1: Open your Jupyter notebook in Deepnote

Log in to your Deepnote account and navigate to the Jupyter Notebook that you want to convert to a Python script.

Step 2: Save your notebook

Before converting, ensure that your notebook is saved. You can click the save button at the top or press `Ctrl + S` (or `Cmd + S` on Mac).

Step 3: Export as a Python script

  • In the notebook interface, look for the option to export or download the notebook. This could be under a 'File' tab or available as an 'Export' or 'Download' button in the interface.
  • Select the option to download or export the notebook as a Python (.py) file. Deepnote typically allows direct downloading in various formats, including Python scripts.

Step 4: Save the Python script locally

Once you've chosen to export the notebook as a Python script, a `.py` file will be generated and downloaded to your local machine's 'Downloads' folder or another location you specify.

Step 5: Review and edit the Python script (optional)

After you have saved the `.py` file, you can open it in your preferred code editor or Integrated Development Environment (IDE). Review the script and make any necessary adjustments such as:

  • Removing or modifying Jupyter-specific commands like magic commands (e.g., `%matplotlib inline`).
  • Adding any required command-line arguments or making it executable as a script by adding a shebang line (`#!/usr/bin/env python3`) at the top of the file.
  • Ensuring all necessary imports are included at the beginning of the script.

Step 6: Run your Python script

To run your new Python script, use your command line or terminal:


Replace `` with the name of the script you've just saved.

These steps will allow you to seamlessly transition from a Jupyter notebook environment provided by Deepnote to a standalone Python script that can be executed independently of the Jupyter ecosystem. Remember that depending on the complexity of your Jupyter notebook, additional steps might be necessary to ensure that your Python script runs as expected outside of the notebook environment.

That’s it, time to try Deepnote

Get started – it’s free
Book a demo



  • Integrations
  • Pricing
  • Documentation
  • Changelog
  • Security




  • Privacy
  • Terms

© Deepnote