KeyError: 'PROJ_LIB'

Hi all,
I am taking my first steps in Obspy, and have been going through the IRIS webinar tutorial. I discovered that a couple of commands in that tutorial have now changed; e.g. cat = obspy.readEvents("./events/2014.ndk") is now cat = obspy.read_events("./events/2014.ndk") and from obspy.fdsn import Client is now from obspy.clients.fdsn import Client.

I got stuck at the following step and can’t seem to figure out a work around. I am on Mac OS and installed Obspy via Anaconda following instructions on the Obspy Wiki. Any help is much appreciated. Thanks!

c.get_stations(network=“TA”, level=“station”).plot(projection=“local”);

Hi Januka,

it seems you're getting hit by this basemap/proj conda packaging issue:

https://github.com/conda-forge/basemap-feedstock/issues/30

You should be able to work around this by doing this:

export PROJ_LIB=$CONDA_PREFIX/share/proj

*after* activating your obspy env and *before* starting python/ipython.

best,
Tobias

Thanks Tobias. This, however, generated a new error (see below). So I reinstalled anaconda + obspy from scratch and updated anaconda to

4.6.2-py37_0, which resolved the issue.

cat.plot();


FileNotFoundError                         Traceback (most recent call last)
<ipython-input-2-de7ef835d031> in <module>
----> 1 cat.plot();

~/anaconda3/envs/obspy/lib/python3.5/site-packages/obspy/core/event/catalog.py in plot(self, projection, resolution, continent_fill_color, water_fill_color, label, color, colormap, show, outfile, method, fig, title, **kwargs)
    650             cat.plot(fig=fig)
    651         """
--> 652         from obspy.imaging.maps import plot_map, _plot_basemap_into_axes
    653         import matplotlib
    654         import matplotlib.pyplot as plt

~/anaconda3/envs/obspy/lib/python3.5/site-packages/obspy/imaging/maps.py in <module>
     33 
     34 if BASEMAP_VERSION:
---> 35     from mpl_toolkits.basemap import Basemap
     36     HAS_BASEMAP = True
     37     if BASEMAP_VERSION < [1, 0, 4]:

~/anaconda3/envs/obspy/lib/python3.5/site-packages/mpl_toolkits/basemap/__init__.py 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={}
    158 for line in epsgf:

FileNotFoundError: [Errno 2] No such file or directory: '/Users/januka/anaconda3/envs/obspy/share/proj/epsg'

Januka Attanayake

Research Fellow | Earthquake Seismology
Homepage: https://sites.google.com/site/janukaattanayake

School of Earth Sciences | McCoy Bldg. 200
University of Melbourne | Parkville 3010 VIC
Australia

Hi Januka,

it seems you’re getting hit by this basemap/proj conda packaging issue:

https://github.com/conda-forge/basemap-feedstock/issues/30

You should be able to work around this by doing this:

export PROJ_LIB=$CONDA_PREFIX/share/proj

after activating your obspy env and before starting python/ipython.

best,
Tobias