Skip to content

building from source creates a __init__.py in mpl_toolkits namespace #456

Closed

Description

@lee218llnl

When I install the 1.2.0 release from source (i.e., python setup.py install), I am unable to import mpl_toolkits.basemap in the resulting installation:

% python -c 'from mpl_toolkits.basemap import Basemap'
Traceback (most recent call last):
File "", line 1, in
ModuleNotFoundError: No module named 'mpl_toolkits.basemap'

I believe this is because of the lib/python3.7/site-packages/basemap-1.2.0-py3.7-linux-x86_64.egg/mpl_toolkits/init.py file. From what I read in https://packaging.python.org/guides/packaging-namespace-packages/, it sounds like the presence of an init.py file in the namespace directory is the cause of this failure:

It is extremely important that every distribution that uses the namespace package omits the init.py or uses a pkgutil-style init.py. If any distribution does not, it will cause the namespace logic to fail and the other sub-packages will not be importable.

Removing this init.py file appears to fix the import problem for me.

Activity

  1. molinav commented on Dec 29, 2021

    @molinav
    Member

    We have recently released basemap version 1.3.0, which includes several changes related to the library packaging. From this version, precompiled wheels are available in PyPI (including your case with Python 3.7 under GNU/Linux x86_64), so you can simply install basemap using pip:

    python -m pip install basemap

    which will install basemap-data in addition. If you also need the high-resolution data files, you need to install basemap-data-hires manually:

    python -m pip install basemap-data-hires

    Hope this helps. If the problem persists, feel free to write here or open a new issue.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions