Bug 559087 - import matplotlib.toolkits.basemap fails
Summary: import matplotlib.toolkits.basemap fails
Keywords:
Status: CLOSED NOTABUG
Alias: None
Product: Fedora EPEL
Classification: Fedora
Component: python-basemap
Version: el5
Hardware: All
OS: Linux
low
medium
Target Milestone: ---
Assignee: Jef Spaleta
QA Contact: Fedora Extras Quality Assurance
URL:
Whiteboard:
Depends On: 559086
Blocks:
TreeView+ depends on / blocked
 
Reported: 2010-01-27 05:05 UTC by Matt Domsch
Modified: 2010-09-27 14:55 UTC (History)
3 users (show)

Fixed In Version:
Doc Type: Bug Fix
Doc Text:
Clone Of: 559086
Environment:
Last Closed: 2010-09-24 12:39:54 UTC
Type: ---
Embargoed:


Attachments (Terms of Use)

Description Matt Domsch 2010-01-27 05:05:48 UTC
+++ This bug was initially created as a clone of Bug #559086 +++

Description of problem:

$ python
Python 2.6.2 (r262:71600, Jan  8 2010, 22:06:26) 
[GCC 4.4.2 20091222 (Red Hat 4.4.2-20)] on linux2
Type "help", "copyright", "credits" or "license" for more information.
>>> import matplotlib.toolkits.basemap
Traceback (most recent call last):
  File "<stdin>", line 1, in <module>
ImportError: No module named toolkits.basemap

This is because there is no __init__.py file in site-packages/matplotlib/toolkits/ to import basemap.  This one line in __init__.py makes it work again:

from basemap import *


Version-Release number of selected component (if applicable):
python-basemap-0.9.5-1.el5

How reproducible:
always

Steps to Reproduce:
1. see above
2.
3.
  
Actual results:
failed import

Expected results:
successful import

Comment 1 Mark Chappell 2010-09-24 12:39:54 UTC
Two things, 

Firstly wrong package, you wanted python-matplotlib rather than python-basemap the hint was in your import line "import matplotlib.toolkits" (not "import basemap")

Secondly, this is not a bug, this is an API change.

See : 
http://www.mail-archive.com/matplotlib-users@lists.sourceforge.net/msg07053.html

>  NOW basemaps won't work any more!  When I run, I get:
>
> Traceback (most recent call last):
>  File "C:\Documents and
> Settings\kpeters\smworkspace\parsesmExcelFile\src\readParse\ExcelClass.py",
> line 13, in <module>
>   from matplotlib.toolkits.basemap import Basemap as Basemap
> ImportError: No module named toolkits.basemap

One of the api changes is that the import line for basemap (and all
matplotlib toolkits) is

  import mpl_toolkits.basemap

rather  than

  import matplotlib.toolkits.basemap

Comment 2 Mark Chappell 2010-09-27 14:55:39 UTC
Moving the conversation from the Fedora ticket (https://bugzilla.redhat.com/show_bug.cgi?id=559086) over to the EPEL ticket

"
Thanks for looking at the bug again.  I wound up doing this in mirrormanager:
# ABI breakage
try:
    # this export sucks - basemap should do this automatically
    os.environ['BASEMAPDATA'] = '/usr/share/basemap'
    from mpl_toolkits.basemap import Basemap
except:
    # python-basemap-0.9.5
    from matplotlib.toolkits.basemap import Basemap
"

EPEL API breakage is kinda sucky. 

Part of me thinks that we should put a very basic matplotlib.toolkits.basemap package in that simply pretends to be mpl_toolkits.basemap just to avoid the API breakage.  But there's only been the one ticket, the update happened 9 months ago, and there also seemed to be a strong demand for the version increment... https://bugzilla.redhat.com/show_bug.cgi?id=502082


Note You need to log in before you can comment on or make changes to this bug.