basemap installation is not successful

Asked 2 years ago, Updated 2 years ago, 127 views

In order to create a code that displays GPS data on a map with matplotlib, I installed basemap, but even if I tried various methods,

Traceback (most recent call last):
File "<stdin>", line 1, in <module>
ImportError: No module named basemap

appears.

Here's how you've done it so far:

$sudo apt-get install python-mpltoolkits.basemap
$wget https://github.com/matplotlib/basemap/archive/v1.0.7rel.tar.gz
$ tar xvf v1.0.7rel.tar.gz
$ cd basemap-1.0.7rel/geos-3.3.3
$ ./configure
$ make
$ sudo make install
$ cd..
$ python setup.py install

Set wget of 2 to git clone and flow of 2.

The above error occurs even though all of them have been completed.
I wondered if numpy and matplotlib were included, but the latest version was installed.My operating system is xubuntu 16.04.
How can I install it?

python ubuntu matplotlib

2022-09-30 21:29

2 Answers

In a Python 3.5 virtual environment in Ubuntu 16.04, it is installed and running with the following commands:

 sudo apt install proj-bin libproj-dev libgeos-dev
pip install https://github.com/matplotlib/basemap/archive/v1.1.0.tar.gz

I tried it on Google Colab and it works.
https://colab.research.google.com/drive/1_Xw_MEIriI0leP-v8vlmhUj6BLJLKmoV

There seems to be a problem with the past basemap installer, so you need to manually configure additional settings.Resolved in v.1.1.0, you can use the rest to install it without any problems.

Cartopy is the successor to basemap.The basemap will run out of support in 2020, and Cartopy will be a little easier to use, so if you want to start now, you should use Cartopy.

To install Cartopy, perform the following:

 sudo apt install proj-bin libproj-dev libgeos-dev
pip install cython numpy
pip install cartopy


2022-09-30 21:29

There was someone who had a problem in exactly the same environment as the questioner.

ImportError: Ubuntu 16.04.3-Installing basemap module on python 2.7.12-Ask Ubuntu

My environment is completely different, but if you try to answer it on this question site,
You may succeed.

The main answer seems to be to use Anaconda.
After installing Anaconda, open the Anaconda prompt and

conda install-canaconda basemap

type

and I can eventually import basemap from mpl_toolkits

Therefore,
we were able to import basemap from a module called mpl_toolkits in the end. It was mentioned.

This is a postscript.
Another answer was found in the article below.

Problem importing a module(mpl_tools.basemap) in Python-Ask Ubuntu

There is a link, so please read it.This sentence was summarized by the respondents.

This article describes how to install basemap. And Here is the git repo, and here is a browser downloadable source code.

This article (with links) describes how to install basemap.And here (with link) is a browser with downloadable source code.

From the article, in short:
1) Download the source if apt-get install does not work out
2) install the source (super useful if installing to a virtual environment) by:
cd basemap-1.x.x
python setup.py install

To put it briefly,
If the apt-get install command ? does not work, download the source.
(Super convenient to install in a virtual environment?) Install the source.

There is also the doc, with installation guides and how to test if you have installed correctly.

And here's the document too.Here's how to test if the installation was successful and the installation guide (import the Basemap at the terminal and run it from mpl(mapplotlib?) toolkits.basemap).

I'm not familiar with it either, so I don't know if it's accurate, but if you follow the link, you'll understand it.


2022-09-30 21:29

If you have any answers or tips


© 2024 OneMinuteCode. All rights reserved.