Skip to content

How to fix Javascript error: ipython is not defined?

Python is one of the most popular programming languages to ever come out, mostly because it’s rather simple for beginners to understand but still powerful enough to write strong code often involving AI, ML and computer vision projects.

There are also hundreds of libraries available for the language that can integrate a number of different features. In this article, we’re taking a look at the “Javascript error: ipython is not defined” error that can come up when using Jupyter lab with Javascript and iPython. 

Also read: Is Python case sensitive when dealing with identifiers?


How to fix the error?

The solution for this is actually quite simple. As you might know already, Jupyter Labs supports interactive matplotlib graphs using the jupyter-matplotlib extension. You can install the extension using Conda or Pip by using the commands given below.

Using Pip

If you’re using Python’s in-built package manager Pip, here’s how you can install the jupyter-matplotlib extension for both Jupyter Labs and Jupyter Labs 2.

pip install ipympl

# If using JupyterLab 2
pip install nodejs
jupyter labextension install @jupyter-widgets/jupyterlab-manager
jupyter labextension install jupyter-matplotlib

Using Conda

Similar to Pip, Conda is also an open-source package manager that acts as an alternate source for many popular libraries. In case Pip doesn’t work for you, or you just prefer using Conda, you can use the following commands based on your situation to install jupyter-matplotlib.

conda install -c conda-forge ipympl

# If using JupyterLab 2
conda install nodejs
jupyter labextension install @jupyter-widgets/jupyterlab-manager
jupyter lab build

# Later, if updating a previous Lab install:
conda install ipympl
jupyter lab build

Once installed, you can use it by adding this line before plotting the graph.

%matplotlib widget

Alternatively, as a workaround you can also configure matplotlib to use inline instead of interactive. It’s not as powerful, but will sidestep the error for you. To use inline, simply add this line before plotting the graph.

%matplotlib inline

Also read: Fix: Python was not found; run without arguments to install 

Hello There!

If you like what you read, please support our publication by sharing it with your friends, family and colleagues. We're an ad-supported publication. So, if you're running an Adblocker, we humbly request you to whitelist us.

We may earn a commission if you buy something from a link on this page. Thanks for your support.







>