Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Import fails due to "is_scalar" error (fresh installation) #439

Closed
paullb514 opened this issue Nov 7, 2018 · 14 comments
Closed

Import fails due to "is_scalar" error (fresh installation) #439

paullb514 opened this issue Nov 7, 2018 · 14 comments

Comments

@paullb514
Copy link

paullb514 commented Nov 7, 2018

Python verison 3.6.4
mathplotlib verison 3.0.1

Simpletest.py test script fails with the following error after compiling from source as per the instructions:

$ python3 simpletest.py
Traceback (most recent call last):
File "simpletest.py", line 1, in
from mpl_toolkits.basemap import Basemap
File "/Library/Frameworks/Python.framework/Versions/3.6/lib/python3.6/site-packages/mpl_toolkits/basemap/init.py", line 17, in
from matplotlib.cbook import is_scalar, dedent
ImportError: cannot import name 'is_scalar'

@paullb514 paullb514 changed the title Cannot import basecamp due to "is_scalar" error Import fails due to "is_scalar" error (fresh installation) Nov 7, 2018
@WeatherGod
Copy link
Member

It looks like you have an older version of basemap. This has already been fixed and is in the released version v1.2.0.

Some notes: basemap is considered deprecated in favor of the cartopy package. Please learn cartopy instead. Second, the preferred method of installing basemap (or cartopy) is through conda-forge due to its complex build process and dependencies.

@paullb514
Copy link
Author

I downloaded the latest version of the website today so if that's the case the page needs ot be updated.

I did ultimately get it going using conda. I will looking into Cartopy as well so thanks for that!

@WeatherGod
Copy link
Member

WeatherGod commented Nov 8, 2018 via email

@samfway
Copy link

samfway commented Nov 27, 2018

Had the same issue, resolved by upgrading basemap:
sudo pip install -U git+https://github.com/matplotlib/basemap.git

@boegel
Copy link

boegel commented Feb 27, 2019

I just ran into this as well, even though I was using the latest version on PyPI (which is 1.0.7), see https://pypi.org/project/basemap/#history .

Any reason why the latest basemap releases are not published on PyPI?

@goyal-vi
Copy link

I'm unable to resolve this issue, even though I'm using the version v1.2.0. I'm using Ubuntu 18.04, python 3.6.
During the execution of configure, I encountered undefined isnan macro error, which I resolved by replacing line 24 in platform.h file with #define HAVE_ISNAN 1.

@maltemuellerm
Copy link

Wher do you find the platform.h?

@davide-p
Copy link

davide-p commented Apr 3, 2019

I managed to solve this "is_scalar" problem by doing what suggested by @samfway, but when running from mpl_toolkits.basemap import Basemap I get the following:
Traceback (most recent call last): File "<stdin>", line 1, in <module> File "/usr/local/lib/python3.6/dist-packages/mpl_toolkits/basemap/__init__.py", line 48, in <module> import _geoslib ImportError: libgeos-3.3.3.so: cannot open shared object file: No such file or directory

Any clue on how to solve this?

@emilhe
Copy link

emilhe commented May 8, 2019

@goyal-vi The error is due to your environment being incompatible (too new) with the old GEOS version. A workaround is to issue the following command before running configure,

export CXX="g++ -std=c++98"

@davide-p The error message simply states that the GEOS library cannot be found. Assuming that you have already compiled it as per the instructions, i.e. with GEOS_DIR=/usr/local, it should be sufficient to modify your LD_LIBRARY_PATH as follows,

export LD_LIBRARY_PATH=$LD_LIBRARY_PATH:/usr/local/lib

@dbpodrasky
Copy link

The source link is still pointing to 1.1.0 on the https://matplotlib.org/basemap/users/installing.html page

@jingqiangye
Copy link

Installing matplotlib in 2.2.0 will work
conda install matploblib=2.2.0

@pc0179
Copy link

pc0179 commented Oct 17, 2019

Maybe I must have missed something? However, I've downloaded Anaconda and setup a virtual python environment specifically to install matplotlib (I tried both versions; 3.1.1 and 2.2.0) as well as basemap v1.2.0 and I am still getting the "cannot import is_scalar" error.
I guess I'll start reading the cartopy docs?

@ChrisVarner
Copy link

Referencing the link comments above (i.e. WeatherGod and dbpodrasky), the download link [https://matplotlib.org/basemap/users/download.html] is still pointing to v1.1.0. That link for basemap is still causing installation issues. samfway's solution above works if you end up on this page.

@ilopezgp
Copy link

ilopezgp commented Jul 5, 2021

This worked for me:

pip install -U matplotlib==3.2
conda install -c conda-forge basemap

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests