matplotlib / basemap

Plot on map projections (with coastlines and political boundaries) using matplotlib
MIT License
780 stars 392 forks source link

FileNotFound when importing basemap #430

Closed statiksof closed 5 years ago

statiksof commented 6 years ago

When I do:

from mpl_toolkits.basemap import Basemap

I get:

---------------------------------------------------------------------------
FileNotFoundError                         Traceback (most recent call last)
<ipython-input-2-b18c5f1c9a35> in <module>()
----> 1 from mpl_toolkits.basemap import Basemap, cm

/opt/conda/lib/python3.6/site-packages/mpl_toolkits/basemap/__init__.py in <module>()
    144 
    145 # create dictionary that maps epsg codes to Basemap kwargs.
--> 146 epsgf = open(os.path.join(pyproj.pyproj_datadir,'epsg'))
    147 epsg_dict={}
    148 for line in epsgf:

FileNotFoundError: [Errno 2] No such file or directory: 'epsg'
gaswani commented 6 years ago

I managed to find a solution to this error. I found the solution at https://conda-forge.org/

In the bash terminal I first typed :

$ conda config --add channels conda-forge

Followed by:

$ conda install basemap

I thereafter ran my script in Juptyer notebook and the error was gone. I was able to plot the Chloropeth map of the world.

statiksof commented 5 years ago

This was fixed for my case by installing the new basemap (instead of the old build) and then setting up the PROJ_LIB in Dockerfile.