[obspy-users] KeyError: 'PROJ_LIB'

Januka Attanayake jattanayake at yahoo.com
Mon Feb 4 03:30:37 CET 2019


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
 


    On Tuesday, January 29, 2019, 9:45:56 PM GMT+11, Tobias Megies <megies at geophysik.uni-muenchen.de> wrote:  
 
 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


On 29/01/2019 05:56, Januka Attanayake wrote:
> 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");
> 
> ---------------------------------------------------------------------------
> KeyError                                  Traceback (most recent call last)
> <ipython-input-11-4054c49eb4d1>  in<module>
> ----> 1c.get_stations(network="TA",  level="station").plot(projection="local");
> 
> ~/anaconda3/envs/obspy/lib/python3.5/site-packages/obspy/core/inventory/inventory.py  inplot(self, projection, resolution, continent_fill_color, 
> water_fill_color, marker, size, label, color, color_per_network, 
> colormap, legend, time, show, outfile, method, fig, **kwargs)
> 701              cat.plot(fig=fig)
> 702          """
> --> 703from  obspy.imaging.mapsimport  plot_map
> 704          import  matplotlib.pyplotas  plt
> 705  
> 
> ~/anaconda3/envs/obspy/lib/python3.5/site-packages/obspy/imaging/maps.py  in<module>
> 33  
> 34  if  BASEMAP_VERSION:
> ---> 35from  mpl_toolkits.basemapimport  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>
> 153  
> 154  # create dictionary that maps epsg codes to Basemap kwargs.
> --> 155pyproj_datadir=  os.environ['PROJ_LIB']
> 156  epsgf=  open(os.path.join(pyproj_datadir,'epsg'))
> 157  epsg_dict={}
> 
> ~/anaconda3/envs/obspy/lib/python3.5/os.py  in__getitem__(self, key)
> 723          except  KeyError:
> 724              # raise KeyError with the original key value
> --> 725raise  KeyError(key)  from  None
> 726          return  self.decodevalue(value)
> 727  
> 
> KeyError: 'PROJ_LIB'
> 
> 
> 
> 
> 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
> 
> _______________________________________________
> obspy-users mailing list
> obspy-users at lists.swapbytes.de
> https://lists.swapbytes.de/mailman/listinfo/obspy-users
> 

-- 
EMail: tobias.megies at lmu.de
WWW: https://www.geophysik.uni-muenchen.de

Geophysikalisches Observatorium
Ludwigshöhe 8
82256 Fürstenfeldbruck

Tel: +49 (0) 89 2180-73981
Fax: +49 (0) 89 2180-73970

Ludwig-Maximilians-Universität
Department für Geo- und Umweltwissenschaften
Sektion Geophysik
Theresienstrasse 41/IV
80333 München

Tel: +49 (0) 89 2180-4326
Fax: +49 (0) 89 2180-4205
_______________________________________________
obspy-users mailing list
obspy-users at lists.swapbytes.de
https://lists.swapbytes.de/mailman/listinfo/obspy-users  
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.swapbytes.de/pipermail/obspy-users/attachments/20190204/f52c64ef/attachment-0001.html>


More information about the obspy-users mailing list