Skip to main content

Publish a Jupyter Notebook as a Medium blogpost

Project description

Jupyter to Medium

PyPI - License

Publish Jupyter Notebooks as Medium blog posts directly from your notebook with the help of jupyter_to_medium.

Target User

Do you ....

  • Publish blog posts on Medium?
  • Use Jupyter Notebooks to write the bulk of your post?
  • Dislike the time and effort it takes to transfer your posts from Jupyter to Medium?

If so, jupyter_to_medium will automate the process of taking your Jupyter Notebook as is and publishing it as a Medium post in almost no time at all saving huge amounts of time.

Motivation

I've published dozens of blog posts on Medium myself with all of them beginning as Jupyter Notebooks. Manually converting them to Medium posts was a fairly lengthy, painstaking process. One particularly painful process was inserting tables, which Medium does not support, into my posts. Nearly all of my posts contain numerous pandas DataFrames (such as this one, which has 40! DataFrames) which are represented as HTML tables within a notebook. I'd take screenshots of each one to insert them into my Medium posts.

Installation

pip install jupyter_to_medium

Automatically activated

You should be able to skip the next step, but if the extension is not showing up in your notebook, run the following command:

jupyter bundlerextension enable --py jupyter_to_medium._bundler --sys-prefix

Get an Integration Token from Medium

Before using this package, you must request an integration token from Medium by emailing them at yourfriends@medium.com allowing you to create a token in your Medium settings. You can read the entire instructions on how to get your integration token.

Creating the integration token

Once your request to create integration tokens is accepted, navigate to your Medium settings. Towards the bottom of the page exists the section on Integration Tokens. Enter a description for the token (jupyter_to_medium is a good choice) and then create the token.

Save your integration token

Once you have your integration token, create the folder and file .jupyter_to_medium/integration_token in your home directory and save the token there. If you don't save it, you'll need to access it every time you wish to make a new post.

Usage

There are three ways to publish notebooks:

  • Within an active notebook
  • Using a Python script
  • From the command line

Publishing to Medium within a Notebook

After installation, open the notebook you wish to publish and select the option File -> Deploy as -> Medium Post

png

A new browser tab will open with a short form that needs to be completed.

png

After clicking publish, the notebook and all images will be uploaded to Medium. Any HTML tables (such as pandas DataFrames) will be converted to images (via chrome), as Medium has no ability to represent tables. This is a time consuming process, so be prepared to wait. Check your terminal for updates. If successful, you'll get the following response with a link to view the post.

png

Click the link to view the post.

png

Finalize and publish on Medium

As of now, your post will be published as a draft. Review and publish the post on Medium.

Publishing to Medium with a Python Script

In a separate script/notebook import juptyer_to_medium as a module. Pass the publish function the location of the Jupyter Notebook you would like to publish as a Medium blog post

>>> import jupyter_to_medium as jtm
>>> jtm.publish('My Awesome Jupyter Notebook.ipynb',
                integration_token=None,
                pub_name=None,
                title=None,
                tags=None,
                publish_status='draft',
                notify_followers=False,
                license='all-rights-reserved',
                canonical_url=None,
                chrome_path=None,
                download_markdown=False)

If successful, JSON data will be returned as a dictionary with the URL.

Publishing to Medium from the Command Line

Upon installation, you'll have access to the command line program jupyter_to_medium with the same options as the above function.

jupyter_to_medium --pub-name="Dunder Data" "My Awesome Blog Post.ipynb"

Dependencies

  • nbconvert
  • requests
  • pillow (if you have HTML tables)
  • Google Chrome / Brave browser

Project details


Download files

Download the file for your platform. If you're not sure which to choose, learn more about installing packages.

Source Distribution

jupyter_to_medium-0.0.10.tar.gz (18.8 kB view details)

Uploaded Source

Built Distribution

jupyter_to_medium-0.0.10-py3-none-any.whl (20.8 kB view details)

Uploaded Python 3

File details

Details for the file jupyter_to_medium-0.0.10.tar.gz.

File metadata

  • Download URL: jupyter_to_medium-0.0.10.tar.gz
  • Upload date:
  • Size: 18.8 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/3.1.1 pkginfo/1.5.0.1 requests/2.23.0 setuptools/46.4.0.post20200518 requests-toolbelt/0.9.1 tqdm/4.46.0 CPython/3.8.3

File hashes

Hashes for jupyter_to_medium-0.0.10.tar.gz
Algorithm Hash digest
SHA256 ff193400b2b52123a130fc98e00b4bbacda2e0d33c49f651967020b1a8d0cd9c
MD5 4175e3af27fc61ef888a942e1cbabc93
BLAKE2b-256 bc77a11187c39eb92c58081a3ffa923461a93eb237549d0289f166ce3ae34f4e

See more details on using hashes here.

File details

Details for the file jupyter_to_medium-0.0.10-py3-none-any.whl.

File metadata

  • Download URL: jupyter_to_medium-0.0.10-py3-none-any.whl
  • Upload date:
  • Size: 20.8 kB
  • Tags: Python 3
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/3.1.1 pkginfo/1.5.0.1 requests/2.23.0 setuptools/46.4.0.post20200518 requests-toolbelt/0.9.1 tqdm/4.46.0 CPython/3.8.3

File hashes

Hashes for jupyter_to_medium-0.0.10-py3-none-any.whl
Algorithm Hash digest
SHA256 1d16c7575b5ad3fbda5a9f63bd3d4cd43713ebb9976b1c79d7a63f3d0a5cc69d
MD5 c8fd09fa1ac7229eb4601925faeb1bec
BLAKE2b-256 faa1a2c10bbfdd5f612ebbb5615ceb7c0fbb4957f8a8aefb4516b42843980d4e

See more details on using hashes here.

Supported by

AWS AWS Cloud computing and Security Sponsor Datadog Datadog Monitoring Fastly Fastly CDN Google Google Download Analytics Microsoft Microsoft PSF Sponsor Pingdom Pingdom Monitoring Sentry Sentry Error logging StatusPage StatusPage Status page