How to Solve Error Message ‘No modules named pyplotlib’ when importing ‘matplotlib.pyplotlib’ in Jupyter Notebook running in Microsoft Windows
Introduction
Before discussing on how to solve the error message, below are the flow of incidents triggering the error message to appear :
-
The error message appear in a running Jupyter Notebook. It run from a Command Line Interface. It is using a device running using Microsoft Windows. As for the Command Line Interface, it is using Command Prompt.
-
There is a virtual python environment in it. But to demonstrate it, just create it if it is not available in the device. As as reference, look at several of the article as reference. The first one is titled ‘How to Create a Python Virtual Environment’ in this link. Another article with similar content exist with the title of ‘How to Create a Python Virtual Environment in Microsoft Windows’ in this link. Another one is also available with the same title of ‘How to Create a Python Virtual Environment in Microsoft Windows’ in this link.
The process for creating virtual python environment is also possible using the help of another tool. Use Anaconda or any other bundled tools to prepare the virtual python environment. Read an article titled ‘How to Create Python Virtual Environment from Anaconda in Microsoft Windows’ in this link. It can also choose for specific version of python to create it. Try to read article titled ‘How to Create a Python Virtual Environment with a specific version of Python in Microsoft Windows’ in this link or another article with the title ‘How to Create a Python 3.6 Virtual Environment’ in this link.
-
After that, activate the virtual python environment. For activating an existing virtual python environment, read the article ‘How to Activate Python Virtual Environment in Microsoft Windows’ in this link. Another article exist with the title of ‘How to Activate Python Virtual Environment after Deactivating Anaconda in Microsoft Windows’ in this link for a reference.
-
Run Jupyter Notebook in the Command Prompt. Specifically, run in the activated virtual python environment. Make sure Jupyter Notebook is installed in the activated python virtual environment. An article exist in this link with the titled of ‘How to Install Jupyter Notebook in Microsoft Windows’ to show how to do it.
-
In the running Jupyter Notebook display, it choose an existing Jupyter Notebook file or to create a new one. Below is the appearance of the Jupyter Notebook :
-
After filling the Jupyter Notebook file with a script or a line of code, an error message appear. That script or line of code is for importing a module named ‘pyplotlib’ exist in ‘matplotlib’ python library package. Furthermore, the error message appeared is ‘No module named matplotlib.pyplotlib’. Below is the appearance of the display which is showing the error message :
Solving the Error Message
There are several options for solving the error message. The main point is that that option is providing a certain way to be able to look to the correct name of the module. In this case, the main purpose is to look for the correct name of ‘pyplotlib’ or any other name which is look alike. Below is the step for achieving it :
-
In the running Jupyter Notebook, run help() function. Below is the appearance of how to execute help() function :
-
In the column or the field which is displayed after executing help() function, insert ‘matplotlib’ as the parameter as in the following image :
-
After insertinng ‘matplotlib’ as the parameter and then pressing enter to execute the script, it will generate detail description about ‘matplotlib’ python library package as in the following image :
In the output generated, fortunately there is an info providing an example for importing a name of module which looks similar. It is ‘pyplot’ instead of ‘pyplotlib’. So, instead of the following line :
import matplotlib.pyplotlib as plt
Change it to the following script below :
import matplotlib.pyplot as plt
As another information, take a look in the following video below. It is showing step by step from the error appearance until the final step to solve the error message. It is by having to execute help() function to retrieve information about existing module available in ‘matplotlib’ python library package which has similar name :