What's the best way to install Matplotlib Basemap toolkit?

Asked by Endolith

I have python-matplotlib installed, but there is no package for the basemap toolkit, described here: http://matplotlib.sourceforge.net/basemap/doc/html/

Installation instructions are here, but I don't understand them: http://matplotlib.sourceforge.net/basemap/doc/html/users/installing.html

For instance, if it says you need GEOS installed, does that mean a package like libgeos-3.0.0 ? Or does it mean something else? Why does it say "that ship with basemap" if I have to install them separately?

Is there a way to use a system like checkinstall so that I can remove all this crap when a real package is released?

Andrew Straw's repository has it, but only for Hardy: http://debs.astraw.com/hardy/ Should I wait for a package to be available there?

Should I use easy_install? http://pypi.python.org/pypi/basemap/ Is there a .deb file somewhere?

Question information

Language:
English Edit question
Status:
Solved
For:
Ubuntu matplotlib Edit question
Assignee:
No assignee Edit question
Solved by:
Endolith
Solved:
Last query:
Last reply:
Revision history for this message
Endolith (endolith) said :
#1

I tried to use easy_install, but it doesn't work (it did work for geopy, which was nice and easy, but not basemap):

apt-get install python-setuptools
sudo easy_install basemap

It gives me errors about not having GEOS:

    checking for GEOS lib in /usr ....
    checking for GEOS lib in /usr/local ....
    checking for GEOS lib in /sw ....
    checking for GEOS lib in /opt ....
    checking for GEOS lib in /opt/local ....
    checking for GEOS lib in /home/endolith ....
    error: Setup script exited with
    Can't find geos library . Please set the
    environment variable GEOS_DIR to point to the location
    where geos is installed (for example, if geos_c.h
    is in /usr/local/include, and libgeos_c is in /usr/local/lib,
    set GEOS_DIR to /usr/local), or edit the setup.py script
    manually and set the variable GEOS_dir (right after the line
    that says "set GEOS_dir manually here".

I installed libgeos-3.0.0 but it still didn't find it. I installed libgeos-dev and it gave me a ton of errors instead, so presumably that's what it needed, but it still doesn't work.

    error: Setup script exited with error: Command "gcc -pthread -fno-strict-aliasing -DNDEBUG -g -fwrapv -O2 -Wall -Wstrict-prototypes -fPIC -Isrc -I/usr/lib/python2.5/site-packages/numpy/core/include -I/usr/include/python2.5 -c src/_proj.c -o build/temp.linux-i686-2.5/src/_proj.o" failed with exit status 1

Revision history for this message
Cyclogenesis (s-collis) said :
#2

I have exactly the same problem... Dualcore intel 64bit Kubuntu...

I also tried installing libgeos 2.2.3 from source and it did not work (died with a refernce to double pointers or something...)

Revision history for this message
Cyclogenesis (s-collis) said :
#3

I have exactly the same problem... Dualcore intel 64bit Kubuntu...

I also tried installing libgeos 2.2.3 from source and it did not work (died with a refernce to double pointers or something...)

Revision history for this message
Cyclogenesis (s-collis) said :
#4

I have exactly the same problem... Dualcore intel 64bit Kubuntu...

I also tried installing libgeos 2.2.3 from source and it did not work (died with a refernce to double pointers or something...)

Revision history for this message
Endolith (endolith) said :
#5

I get a ton of errors like

    src/_proj.c:1898: error: expected '=', ',', ';', 'asm' or '__attribute__' before '*' token
    src/_proj.c:2334: error: '__pyx_kp___cinit__' undeclared here (not in a function)
    src/_proj.c:2334: warning: excess elements in struct initializer
    src/_proj.c:2334: warning: (near initialization for '__pyx_string_tab[0]')
    src/_proj.c:2334: warning: excess elements in struct initializer
    src/_proj.c:2334: warning: (near initialization for '__pyx_string_tab[0]')
    src/_proj.c:2334: warning: excess elements in struct initializer
    src/_proj.c:2334: warning: (near initialization for '__pyx_string_tab[0]')
    src/_proj.c:2334: warning: excess elements in struct initializer
    src/_proj.c:2334: warning: (near initialization for '__pyx_string_tab[0]')
    src/_proj.c:2334: warning: excess elements in struct initializer
    src/_proj.c:2334: warning: (near initialization for '__pyx_string_tab[0]')

I installed proj and httplib2 but it still won't work.

Revision history for this message
Endolith (endolith) said :
#6

Mailing list post about the same issue:

http://www.nabble.com/All-kinds-of-issues-inslalling-basemap-under-Ubuntu-8.10-64bit--SEC%3DUNCLASSIFIED--td21329001.html

Looks like we need more dev packages because easy_install actually compiles stuff.

Revision history for this message
Endolith (endolith) said :
#7

I really don't understand all of this, but this at least seems to have worked:

    sudo apt-get install python-matplotlib python-numpy libgeos-dev python-httplib2 python-imaging python-dev
    tar xvfz basemap-0.99.2.tar.gz
    cd basemap-0.99.2/
    sudo checkinstall sudo python setup.py install

No other combination of sudos on the last step worked, so I hope that is right.

The .deb file it creates is only 27k, but I guess that's what checkinstall does. I am skeptical if it would actually uninstall basemap successfully if I tried.

This command now works:

    from mpl_toolkits.basemap import Basemap

and I can see all the subparts with tab completion:

    In [2]: Basemap.
    Basemap.__base__ Basemap.__module__ Basemap.bluemarble Basemap.imshow
    Basemap.__bases__ Basemap.__mro__ Basemap.contour Basemap.makegrid
    Basemap.__basicsize__ Basemap.__name__ Basemap.contourf Basemap.mro
    Basemap.__call__ Basemap.__new__ Basemap.drawcoastlines Basemap.pcolor
    Basemap.__class__ Basemap.__reduce__ Basemap.drawcountries Basemap.pcolormesh
    Basemap.__cmp__ Basemap.__reduce_ex__ Basemap.drawgreatcircle Basemap.plot
    Basemap.__delattr__ Basemap.__repr__ Basemap.drawlsmask Basemap.quiver
    Basemap.__dict__ Basemap.__setattr__ Basemap.drawmapboundary Basemap.readshapefile
    Basemap.__dictoffset__ Basemap.__str__ Basemap.drawmapscale Basemap.rotate_vector
    Basemap.__doc__ Basemap.__subclasses__ Basemap.drawmeridians Basemap.scatter
    Basemap.__flags__ Basemap.__weakref__ Basemap.drawparallels Basemap.set_axes_limits
    Basemap.__getattribute__ Basemap.__weakrefoffset__ Basemap.drawrivers Basemap.tissot
    Basemap.__hash__ Basemap._getmapboundary Basemap.drawstates Basemap.transform_scalar
    Basemap.__init__ Basemap._readboundarydata Basemap.fillcontinents Basemap.transform_vector
    Basemap.__itemsize__ Basemap.barbs Basemap.gcpoints Basemap.warpimage

I did not modify any source code as described in the mailing list. Just the above commands.

I'll do some real tests later to see if it really works.

Revision history for this message
Endolith (endolith) said :
#8

I tested a bunch of examples and it seems to be working!

Revision history for this message
Endolith (endolith) said :
#9

This worked in Jaunty, too.

    sudo apt-get install python-matplotlib python-numpy libgeos-dev python-httplib2 python-imaging python-dev checkinstall
    tar xvfz basemap-0.99.3.tar.gz
    cd basemap-0.99.3/
    sudo su
    checkinstall python setup.py install

Then I filled in number 10 with "python-matplotlib, python-numpy, libgeos-dev, python-httplib2, python-imaging, python-dev"

It installed, and the demos run, but when I tried to uninstall it still works. :) So it's installed permanently and checkinstall apparently can't handle python installations

Revision history for this message
Endolith (endolith) said :
#10

In Karmic:

    sudo su
    apt-get install python-matplotlib python-numpy libgeos-dev python-httplib2 python-imaging python-dev checkinstall
    tar xvfz basemap-0.99.4.tar.gz
    cd basemap-0.99.4/
    checkinstall python setup.py install

Then typed number 10, changed to python-matplotlib, python-numpy, libgeos-dev, python-httplib2, python-imaging, python-dev
Then it goes into interactive mode (?)
So I chose option 2 - install, and it worked!

Revision history for this message
sharaf (sfalsharif) said :
#11

How did you manage to solve the GEOS problem? I'm using Lucid, and I also get the same error:

Can't find geos library . Please set the
environment variable GEOS_DIR to point to the location

when I try the exact steps described by Endolith above.

Revision history for this message
Endolith (endolith) said :
#12

Did you search synaptic for "geos" to try to find what name the library might be under? I'm not at a computer right now

Revision history for this message
kiran (kiranch) said :
#13

Try to search for "libgeos-dev" in synaptic and then download the tar package for basemap.. execute it with

python setup.py install

then it should work