0

I have alredy installed matplotlib on my venv in Pycharm. I tried to run it in Jupyter Notebook and them I got noticement No module named 'matplotlib'

I also tried to run !pip install matplotlib at the first cell in my .ipynb file and then I got:

Requirement already satisfied: matplotlib in c:\users\user\pycharmprojects\ege\venv\lib\site-packages (3.8.2)
Requirement already satisfied: contourpy>=1.0.1 in c:\users\user\pycharmprojects\ege\venv\lib\site-packages (from matplotlib) (1.2.0)
Requirement already satisfied: cycler>=0.10 in c:\users\user\pycharmprojects\ege\venv\lib\site-packages (from matplotlib) (0.12.1)
Requirement already satisfied: fonttools>=4.22.0 in c:\users\user\pycharmprojects\ege\venv\lib\site-packages (from matplotlib) (4.45.0)
Requirement already satisfied: kiwisolver>=1.3.1 in c:\users\user\pycharmprojects\ege\venv\lib\site-packages (from matplotlib) (1.4.5)
Requirement already satisfied: numpy<2,>=1.21 in c:\users\user\pycharmprojects\ege\venv\lib\site-packages (from matplotlib) (1.26.2)
Requirement already satisfied: packaging>=20.0 in c:\users\user\pycharmprojects\ege\venv\lib\site-packages (from matplotlib) (23.2)
Requirement already satisfied: pillow>=8 in c:\users\user\pycharmprojects\ege\venv\lib\site-packages (from matplotlib) (10.1.0)
Requirement already satisfied: pyparsing>=2.3.1 in c:\users\user\pycharmprojects\ege\venv\lib\site-packages (from matplotlib) (3.1.1)
Requirement already satisfied: python-dateutil>=2.7 in c:\users\user\pycharmprojects\ege\venv\lib\site-packages (from matplotlib) (2.8.2)
Requirement already satisfied: six>=1.5 in c:\users\user\pycharmprojects\ege\venv\lib\site-packages (from python-dateutil>=2.7->matplotlib) (1.16.0)

after that I tried to start code at the second cell: import matplotlib.pyplot as plt

and I got this:

---------------------------------------------------------------------------
ModuleNotFoundError                       Traceback (most recent call last)
Cell In[5], line 1
----> 1 import matplotlib.pyplot as plt

ModuleNotFoundError: No module named 'matplotlib'

I also tried: pip install ipykernel

what should I try to solve this problem?

3
  • The OP was using outdated approach. For carrying out installation in a cell of the notebook, the command that should be used today is %pip install matplotlib. The magic variation was added in 2019 to ensure the install occurs in the environment where the kernel is running that backs the active notebook. The exclamation point doesn't do that and can lead to issues. See more about the modern %pip install command here. ... Commented Apr 7 at 20:09
  • <continued> The second paragraph here goes into more details about why the exclamation point may lead to issues, which happen to be similar to what the OP reported experiencing here. Commented Apr 7 at 20:09
  • As for the root issue. Jupyter is very particular about the environment it uses. Just because you start it up in the environment the venv is in doesn't mean it uses that without additional steps. See here and errorLogger's comment here. Also see here, here, and here. Commented Apr 7 at 20:22

1 Answer 1

0

delete and install or otherwise discard your current environment and make a new one and then install the library or the last option which you can do is use a older version of Jupyter.

Sign up to request clarification or add additional context in comments.

2 Comments

This is unclear. Why would the OP need to use an older version of Jupyter?
As it’s currently written, your answer is unclear. Please edit to add additional details that will help others understand how this addresses the question asked. You can find more information on how to write good answers in the help center.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.