AI-Powered Code Completion in JupyterLab

Power up the almost useless code suggestions in JupyterLab

Robert Ritz
Towards Data Science

--

JupyterLab’s native code completion is well….not great.

As a data scientist, you almost surely use a form of Jupyter Notebooks. Hopefully, you have moved over to the goodness of JupyterLab with its integrated sidebar, tabs, and more. When it first launched in 2018, JupyterLab was great but felt it was missing some things.

Now you can add a visual debugger and there is even a library called nbdev that allows you to author full Python packages and push them to PyPI. JupyterLab has become a complete IDE for data scientists. But one thing was still sub-optimal until recently, code completions.

Trying to use the built-in code completion in JupyterLab gets you something like this:

When you do really ever want the absolute value of a whole dataframe?

Kite, a company that makes code completion software for a variety of languages and IDE’s, recently launched Kite for JupyterLab. Now you can get something like this:

That makes much more sense.

Simplify your life with logical autocompletion. It runs locally and doesn’t send your code to the cloud.

Yes, I DO want plt.plot(). Thanks.

It isn’t perfect, and it certainly doesn’t read your mind. It IS a good upgrade for the default code completion though.

Kite for JupyterLab brings you one step closer to a full notebook based IDE.

How to Install Kite for JupyterLab

Installing Kite for JupyterLab is fairly painless.

  1. First, install Kite for Desktop. You can get the installer here. Versions are available for Windows, Mac, and Linux.
  2. Make sure your JupyterLab is version 2.2 or later. This is a pretty recent version of JupyterLab so you may need to upgrade with your install with conda or pip.
  3. Install the JupyterLab extension. You will need NodeJS installed just like for your other extensions.
pip install jupyter-kitejupyter labextension install "@kiteco/jupyterlab-kite"

My experience so far

I’ve only used Kite for JupyterLab for about a week now. It’s not groundbreaking, but it certainly makes my coding experience that much better. Completions are noticeably faster than the native completions as well.

I’m using the free version of Kite, and the completions take place 100% locally. The best suggestion for me isn’t always at the top, but it’s usually in the top 5. As data scientists, we use LOTS of methods, and this is a nice way to get reminders when needed.

Happy coding!

Thanks for reading. You can find more about me here. Consider subscribing to get notifications when I publish. If you would like to directly support my articles you can use my referral link to sign up to become a Medium member.

--

--