Visualizing data using basemap

I am not able to run Basemap codes in dataquest portal. Everytime i run, my code is timed-out. I tried in jupyter notebook but there I am getting Error : Proj Lib. I tried stackflow but none of the solution worked for me.


Can you show us the piece of code that fails please?


@Maxime I have the same issue as amjad21khan’s.

I installed everything according to stackoverflow suggested.

  1. pyproj
  2. numpy
  3. matplotlib
  4. GEOS
  5. basemap

Here is the error info from my jupyter notebook;

KeyError                                  Traceback (most recent call last)
<ipython-input-6-d9467465a3b6> in <module>
----> 1 from mpl_toolkits.basemap import Basemap

~\Anaconda3\lib\site-packages\mpl_toolkits\basemap\ in <module>
    154 # create dictionary that maps epsg codes to Basemap kwargs.
--> 155 pyproj_datadir = os.environ['PROJ_LIB']
    156 epsgf = open(os.path.join(pyproj_datadir,'epsg'))
    157 epsg_dict={}

~\Anaconda3\lib\ in __getitem__(self, key)
    676         except KeyError:
    677             # raise KeyError with the original key value
--> 678             raise KeyError(key) from None
    679         return self.decodevalue(value)

KeyError: 'PROJ_LIB'

Hi @yoyotooie,

I assume you are using Windows OS, please try adding this code (after making changes according to the username and proj4 folder name) at the top of your code:

import os
os.environ['PROJ_LIB'] = (r'C:\Users\<username>\AppData\Local\Continuum\anaconda3\pkgs\proj4-<complete_folder_name>\Library\share')

Hope this works for you.


1 Like