ImportError: cannot import name 'is_scalar' - python

I am importing the Basemap package from mpl_toolkits.basemap.
from mpl_toolkits.basemap import Basemap
Tried: Updating the version of matplotlib
But still, it throws an error:
ImportError: cannot import name 'is_scalar'

I found this on GitHub, maybe one of these solutions will work for you.

I had the same problem, it appears to have been fixed in a newer version of basemap. After compiling from source it worked for me
git clone https://github.com/matplotlib/basemap.git
cd basemap
pip install .
After doing this, you can test your basemap installation to verify it works correctly:
cd examples
python simpletest.py

Related

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

Facing Import Error while running the imported packages in jupyter notebook of VS code

Error: ImportError: dlopen(/Library/Frameworks/Python.framework/Versions/3.10/lib/python3.10/site-packages/PIL/_imaging.cpython-310-darwin.so, 0x0002): symbol not found in flat namespace '_xcb_connect'
Below is the piece of code I'm trying execute
Declarations and imports
import warnings
warnings.filterwarnings('ignore')
import pandas as pd
import numpy as np
from matplotlib import pyplot as plt
The complete Screenshot
enter image description here
Thanks in advance for helping out
I faced the same issue on Mac M1 chip with pyodbc library, I resolved this and it worked for me, hope it will helps you as well.
I managed to fix it with a --no-binary option which forces pip to compile the module from source instead of installing from precompiled wheel.
pip uninstall pyodbc
pip install --no-binary :all: pyodbc
The error seems to happen on Mac M1. Reverting to 9.0.0 fixes the issue.
I think it's related to this issue: https://github.com/python-pillow/Pillow/issues/6015.
Running: pip install pillow==9.0.0 should fix it.

cannot import name '_nd_image' - SCIPY

I'm having this problem:
File "C:\IntelPython3\lib\site-packages\scipy\ndimage\filters.py", line 37, in
from . import _nd_image
ImportError: cannot import name '_nd_image'
I was checking in that path and i can't find any module or something called nd_image but i've looked for all the scipy releases and i can't find it too.
Can someone help please? (WINDOWS)
You might be using the older version of scipy with the latest version of python.
You should upgrade scipy to solve the problem by typing below command line.
pip install --upgrade scipy
If you are not using pip in Window, you can use conda or other things.
And actually, you can not find _nd_image.py module. This question might be helpful.

Error in matplotlib import with Wakari

I am trying to import matplotlib into an iPython notebook using Wakari, with the Anaconda environment np18py27-1.9. I am importing using:
%matplotlib inline
import matplotlib.pyplot as plt
This yields the error:
ImportError: libpng15.so.15: cannot open shared object file: No such file or directory
Because it is Wakari, I don't think I can update or reinstall the matplotlib package. Importing pylab throws the same error. Do you have any suggestions? Thanks for your help.
Edit:
I was able to update matplotlib in my Wakari environment. I am now getting the following error:
ImportError: libXext.so.6: cannot open shared object file: No such file or directory
Well .so files are shared libraries and (for what reasons I have no idea) you don't have them.
For your second error regarding libXext.so the answers generally suggested are sudo apt-get update && sudo apt-get install libxtst6

Problems installing/importing Basemap

I have installed Anaconda (version 1.6.2) installed on my 64 bit machine. It comes with a great set of libraries, but I also need Basemap, part of matlibplot, but it is not included with the Anaconda install. I attempted to install Basemap and move the files in the Anacaonda\Lib\site-packages\mpl_toolkits directory since it is part of the mpl_toolkits library. However when I attempt to run a script, I keep getting the errors:
"No module named _geoslib"
"Cannot import pyproj"
I found the pyproj library. Do I need it? Where can I find geoslib? And how do I get Basemap to work?
What you nees is to change your path first, by:
$ export PATH=~/anaconda/bin:$PATH
and then,
$ conda install basemap
( I assumed you are in Linux)
source:http://docs.continuum.io/anaconda/faq.html
If your on Windows try installing Basemap from the Sourceforge executable, these should include GEOS and PROJ4 dependencies of Basemap.
I believe all that is needed is to update matplotlib, I just had this problem and doing this worked for me:
pip install --upgrade matplotlib

Categories