Cannot import name cbook in jupyter - python

I have matplotlib-2.2.3 installed. When I used matplotlib in jupyter, it throws the following error:
ImportError: cannot import name cbook in jupyter
All is OK when I run the code in PyCharm. I used python 2.7 and I have tried many suggestions like that in ImportError: cannot import name cbook but none worked.
I finally found the solution that downgrade the matplotlib and six, and that solves my question.
pip install six==1.10.0
pip install matplotlib==2.0.2

Related

I can't get Seaborn to import

I'm trying to add Seaborn to my Anaconda3 python installation, and get multiple failure codes. It successfully installed using conda ... but won't import. After multiple installs/deletion/reinstalls of scipy, numpy, and seaborn, I get the following error message. I'm running Python 3.9.12, numpy 1.22.0 (downgraded from 1.23 due to prev error message stating had to be < 1.23 for Seaborn to install -- on a Windows 10. Any suggestions would be appreciated.
I can't post an image yet, so here's a summary of the error message with the failure points
code:
import Seaborn as sns
ImportError
...
import seaborn as sns
from .rcmod import * # noqa:F401, F403
from .import palettes
from . import _arpack
ImportError: DLL load failed while importing _arpack: The specified procedure could not be found.
It is not issue of seaborn. First of all uninstall numpy using this command
pip uninstall -y numpy
Then uninstall setuptools with this command
pip uninstall -y setuptools
Now, reinstall setuptools with this command
pip install setuptools
Then, You can reinstall numpy with this command
pip install numpy
Now, Your error must be solved.

geopandas read_file function causes ImportError

I just got a new computer and after downloading the newest version of the anaconda distribution I tried to install geopandas and run my script.
However, the gpd.read_file command causes an ImportError.
I have been trying to reinstall everything but nothing changed.
Does anybody know how to figure this out?
import geopandas as gpd
path = "C:/someshapefile.shp"
gpd.read_file(path)
ImportError: The 'read_file' function requires the 'pyogrio' or
'fiona' package, but neither is installed or imports correctly.
Importing fiona resulted in:
DLL load failed while importing ogrext: The specified module could not be found.
Importing pyogrio resulted in:
No module named 'pyogrio'
Just installing fiona manually like this:
conda install -c conda-forge fiona
did unfortunately not work for me.
Thanks a lot!
CM
git issue comment
python -m pip install git+https://github.com/Toblerity/Fiona.git
working for me

Trouble installing 'matplotlib'

Cant' install 'matplotlib.pyplot' on Windows 10, Python 3.7
I tried 'pip install matplotlib.pyplot' and received an error
Here's the exact error code:
Could not find a version that satisfies the requirement matplotlib.pyplot (from versions: )
No matching distribution found for matplotlib.pyplot
Don't use pip install matplotlib.pyplot, use pip install matplotlib
matplotlib.pyplot is calling pyplot from the module matplotlib. What you want is the module, matplotlib. Then from idle or wherever you are running this, you can call matplotlib.pyplot
Try just using pip install on your command line (or terminal):
'pip install matplotlib'
I hope it helps.
BR

ImportError: No module named artist

I tried to upgrade matplotlib using pip install --upgrade matplotlib, then after upgrading an import error occurred: import matplotlib.pyplot as plt
ImportError: No module named artist
The whole error is:
---------------------------------------------------------------------------
ImportError Traceback (most recent call last)
<ipython-input-18-eff513f636fd> in <module>()
----> 1 import matplotlib.pyplot as plt
C:\Users\TZ\AppData\Local\Continuum\Anaconda2\lib\site-packages\matplotlib\pyplot.py in <module>()
25
26 import matplotlib
---> 27 import matplotlib.colorbar
28 from matplotlib import style
29 from matplotlib import _pylab_helpers, interactive
C:\Users\TZ\AppData\Local\Continuum\Anaconda2\lib\site-packages\matplotlib\colorbar.py in <module>()
30
31 import matplotlib as mpl
---> 32 import matplotlib.artist as martist
33 import matplotlib.cbook as cbook
34 import matplotlib.collections as collections
ImportError: No module named artist
Anyone could solve this problem? (PS: I use python 2.7)
When I faced this issue (system: Windows - 64 bit OS) after upgrading Anaconda to the latest version (yesterday), I saw that Anaconda was trying to load the package from a location different from the default site-packages. Hence:
I fist checked the path my jupyter notebook was defaulting to as mentioned in one of the git hub posts (sorry I don't remember which one) using:
import sys
print(sys.path)
Since this path is not the default site-packages folder, I uninstalled Anaconda completely from add or remove programs - Anaconda (this will take some time to uninstall)
Anaconda will also remove jupyter notebook from your system. Hence, just reinstall jupyter notebook alone and open it from command line using
jupyter notebook
When you now try to import the matplotlib.pyplot in your notebook, it should not give any errors and you can use the same sys.path to check the path it is defaulting to. It should look something like:
Now, it is importing from the site-packages folder.
I am yet to investigate why and how this issue was caused but removing the upgraded Anaconda version helped me.
Run this command on your prompt:
pip install --user matplotlib --force
If it asks any packages related to it. Please install them also . It succeded for me. I hope for you also
Running this command worked for me:
conda install matplotlib --force

get Error: 'no module named 'matplotlib.style' while matplotlib works fine

I'm using PyCharm on an ubuntu 14.04.1 LTS with python3. I want to use the 'ggplot' style module, but I get an 'no module named' error. Matplotlib 1.3.1 is installed and works fine (I updated it recently).
import matplotlib as mpl
import matplotlib.style as mplstyle
mplstyle.use('ggplot')
ImportError: No module named 'matplotlib.style'
I also checked for the matplotlibrc file and matplotlibtool and everything seems to be as the documentation recommends. Anyone knows, what I can do?
According to What's new in matplotlib, the style package was added to matplotlib since version 1.4.
So, check your matplotlib version by,
$ pip freeze | grep matplotlib
matplotlib==1.3.1
Upgrade matplotlib to the newest version by,
$ sudo pip install matplotlib --upgrade
$ pip freeze | grep matplotlib
matplotlib==1.5.1
This works fine for me.
import matplotlib.pyplot as plt
plt.style.use('ggplot')

Categories