Skip to content

mpl_toolkits.basemap fails to import #3813

@lee218llnl

Description

@lee218llnl

I'm having trouble importing mpl_toolkits.basemap. I know this had previously worked, so I don't know where to point the finger. Here's what I see:

[lee218@rzwiz2:spack.basemap]$ /nfs/tmp2/lee218/delete/spack.basemap/opt/spack/linux-rhel7-x86_64/gcc-4.8.5/python-2.7.13-gcx7wpxjtt7ujlpbahezikqfz4xn2ul6/bin/python -c 'import mpl_toolkits; print(mpl_toolkits.__path__); import mpl_toolkits.basemap'
['/nfs/tmp2/lee218/delete/spack.basemap/opt/spack/linux-rhel7-x86_64/gcc-4.8.5/python-2.7.13-gcx7wpxjtt7ujlpbahezikqfz4xn2ul6/lib/python2.7/site-packages/matplotlib-2.0.0-py2.7-linux-x86_64.egg/mpl_toolkits']
Traceback (most recent call last):
  File "<string>", line 1, in <module>
ImportError: No module named basemap

[lee218@rzwiz2:spack.basemap]$ /nfs/tmp2/lee218/delete/spack.basemap/opt/spack/linux-rhel7-x86_64/gcc-4.8.5/python-3.6.0-ndtiujzzf7p4m5t4k6xergu3f2u674sk/bin/python3 -c 'import mpl_toolkits; print(mpl_toolkits.__path__); import mpl_toolkits.basemap'
['/nfs/tmp2/lee218/delete/spack.basemap/opt/spack/linux-rhel7-x86_64/gcc-4.8.5/python-3.6.0-ndtiujzzf7p4m5t4k6xergu3f2u674sk/lib/python3.6/site-packages/matplotlib-2.0.0-py3.6-linux-x86_64.egg/mpl_toolkits']
Traceback (most recent call last):
  File "<string>", line 1, in <module>
ModuleNotFoundError: No module named 'mpl_toolkits.basemap'

With a previous installation I see this:

[lee218@rzwiz2:spack.basemap]$ python -c 'import mpl_toolkits; print(mpl_toolkits.__path__); import mpl_toolkits.basemap' ['/collab/usr/gapps/python/build/spack-toss3.1/opt/spack/linux-rhel7-x86_64/gcc-4.8.5/python-2.7.13-gv7myy57t2h6wp44f42b2llku7kiva7z/lib/python2.7/site-packages/matplotlib-1.5.3-py2.7-linux-x86_64.egg/mpl_toolkits', '/collab/usr/gapps/python/build/spack-toss3.1/opt/spack/linux-rhel7-x86_64/gcc-4.8.5/python-2.7.13-gv7myy57t2h6wp44f42b2llku7kiva7z/lib/python2.7/site-packages/mpl_toolkits']

Notice that the path in the latter case includes the mpl_toolkits directory where basemap exists. I'm not sure why the old Spack python build was able to find both the matplotlib and basemap mpl_toolkits directories, while the new Spack python build only finds the maplotlib one. Any thoughts @tgamblin @citibeth @adamjstewart @mathstuf?

I found one hack that works around this, which is to add __path__.append('/nfs/tmp2/lee218/delete/spack.basemap/opt/spack/linux-rhel7-x86_64/gcc-4.8.5/py-basemap-1.0.7-cs5yvwpwtosqpl3t7rhadlccinbmsqvr/lib/python3.6/site-packages/mpl_toolkits') to .../matplotlib.../mpl_toolkits/init.py.

Metadata

Metadata

Assignees

No one assigned

    Labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions