Python Forum
importing matplotlib in jupyter notebook
Thread Rating:
  • 0 Vote(s) - 0 Average
  • 1
  • 2
  • 3
  • 4
  • 5
importing matplotlib in jupyter notebook
#1
The following code produces the following error;


import pandas as pd
from matplotlib import pyplot as plt
import math
import re
import numpy as np
import feather
from sklearn.ensemble import RandomForestClassifier, GradientBoostingClassifier
from sklearn.model_selection import train_test_split, GridSearchCV
from sklearn.pipeline import Pipeline
from sklearn.linear_model import SGDClassifier
from xgboost import XGBClassifier
from lightgbm import LGBMClassifier
from datetime import date
from dateutil.parser import isoparse
from pandas.plotting import table
The error is now shown:

Error:
ImportError Traceback (most recent call last) <ipython-input-2-53f378af38b1> in <module>() 1 import pandas as pd ----> 2 from matplotlib import pyplot as plt 3 import math 4 import re 5 import numpy as np C:\Users\james\miniconda3\envs\py-dep\lib\site-packages\matplotlib\__init__.py in <module>() 172 173 --> 174 _check_versions() 175 176 C:\Users\james\miniconda3\envs\py-dep\lib\site-packages\matplotlib\__init__.py in _check_versions() 157 # Quickfix to ensure Microsoft Visual C++ redistributable 158 # DLLs are loaded before importing kiwisolver --> 159 from . import ft2font 160 161 for modname, minver in [ ImportError: DLL load failed: The specified module could not be found.
I am using matplotlib and matplotlib-base ver 3.3.3

I am also using python 3.8.2.

I do not know how to get rid of this error?

Thanks in adavnce.

Respectfully,

LZ
Reply
#2
Are you certain that matplotlip is installed in that particular environment?
Reply
#3
You most active environment,then it look like this.
(py-dep) C:\Users\james\miniconda3\envs\py-dep\...
Most always activate environment in Anaconda (base) or own made environment.
Earlier version could get away not activate environment,but not anymore.
Look at this post.
Reply
#4
I clicked on the miniconda command activate in my Windows 10 program list. From there I typed in Jupyter notebook and onece the IDE is up and running I switch to playcall virtual environment by the drop down menu in the upper right hand corner. From there I loaded the ipynb file and then hit run all.

That is how I got the 1st. error.

In the last hour I click on miniconda jupyter environment. It brings up a command line from the command line I activated the playcall virtual environment. I had previously downloaded a *.py of the playcall python code.

Then I type

python playcall.py


This time it ran from the command line. It crashed on the import feather line.

I thought, that I had taken care of that. I used the command:

conda install feather-format -c conda-forge

It seemed to work and I guess that I had not.

I know that you just do not type conda install feather.

Respectfully,

LZ
Reply
#5
(Feb-25-2021, 05:53 PM)Led_Zeppelin Wrote: I clicked on the miniconda command activate in my Windows 10 program list
You should probably not click on anything,most learn to to all from command line.
Eg use Anaconda Prompt,i use cmder(as it's much better that cmd/powershell).

When you have py-de in envs dos it means that this is virtual environment.
Then most activate py-de to use it.
miniconda3\envs\py-de\...
Quick demo and i use Anaconda prompt for this demo,and new_env as i made it before in link posted.

# See (base) environment is active 
(base) PS C:\Users\Tom> conda activate new_env

# new_env is activated,for you py-de
(new_env) PS C:\Users\Tom>

# Test python 
(new_env) PS C:\Users\Tom> python -V
Python 3.9.1

# Test pip see that it point to new_env folder.
(new_env) PS C:\Users\Tom> pip -V
pip 20.3.3 from C:\Anaconda3\envs\new_env\lib\site-packages\pip (python 3.9)

# Test conda
(new_env) PS C:\Users\Tom> conda -V
conda 4.9.2
Reply


Possibly Related Threads…
Thread Author Replies Views Last Post
  My code works on Jupyter Lab/Notebook, but NOT on Visual Code Editor jst 4 876 Nov-15-2023, 06:56 PM
Last Post: jst
  Navigating file directories and paths inside Jupyter Notebook Mark17 5 629 Oct-29-2023, 12:40 PM
Last Post: Mark17
  How to programmatically stop a program in Jupyter Notebook? Mark17 11 36,296 Feb-12-2023, 01:41 PM
Last Post: jp21in
Thumbs Up Python 3 Jupyter notebook ternary plot data nicholas 0 896 Jan-21-2023, 05:01 PM
Last Post: nicholas
  Graphs from Jupyter notebook to word Scott 0 837 Nov-28-2022, 06:16 AM
Last Post: Scott
  Opening an empty Jupyter notebook in VSCODE Krischu 3 1,771 Mar-09-2022, 01:57 PM
Last Post: Larz60+
  How to do line continuation in Jupyter Notebook? Mark17 4 5,359 Sep-22-2021, 04:22 PM
Last Post: ibreeden
  Jupyter Notebook as IDE bytecrunch 0 1,580 Sep-12-2021, 07:41 PM
Last Post: bytecrunch
  Importing module in jupyter Noteboook ajitnayak1987 0 1,725 Jun-04-2021, 12:26 PM
Last Post: ajitnayak1987
  It says there is no keras in jupyter notebook. it is wrong there is a keras install Led_Zeppelin 0 1,849 Apr-27-2021, 08:29 PM
Last Post: Led_Zeppelin

Forum Jump:

User Panel Messages

Announcements
Announcement #1 8/1/2020
Announcement #2 8/2/2020
Announcement #3 8/6/2020