Basemap hack for folks that are having issues with Conda

1,665 views
Skip to first unread message

Scott Collis

unread,
Sep 20, 2018, 9:55:14 AM9/20/18
to Py-ART Users
See the discussion here:

Py-ART has a required dependency of Basemap. This is going away real soon as Basemap will be out of support in 2020

If you get the key error add:
os.environ['PROJ_LIB'] = ‘/PATH_TO_ANANCONDA_ENV/share/proj/‘

Eg 

os.environ['PROJ_LIB'] = '/home/scollis/anaconda3/envs/dasktestj/share/proj/‘

For those that are using Py-ART in Dask (hint: the new Dask JobQueue makes it easier than ever working on a cluster) here is an example how you can execute this on all nodes

cluster = PBSCluster(processes = 18)
cluster.scale(4)         # Ask for 4*18 workers
client = Client(cluster)  # Connect this local process to remote workers

def com():
    os.environ['PROJ_LIB'] = '/home/scollis/anaconda3/envs/dasktestj/share/proj/'
    from mpl_toolkits.basemap import Basemap
    return os.environ['PROJ_LIB']


client.run(com)

I hope this helps any heartache.

If you use Basemap it is now time to learn Cartopy.


Scott Collis


Mariana Scott

unread,
Mar 5, 2019, 11:33:11 AM3/5/19
to Py-ART Users
I installed pyart following these instructions: https://github.com/ARM-DOE/pyart/wiki/Simple-Install-of-Py-ART-using-Anaconda  (Conda 4.6.7) on a Windows 10 computer (python 3.6.7) and am getting the KeyError: 'PROJ_LIB' when executing import pyart on Spyder..

Could you give any more information about how you fixed this? Where would I add os.environ['PROJ_LIB'] = ... command?
also, is "/share/proj/" supposed to be contained in that path? is this the "envs directories" when I do a conda info?

Thanks,
Mariana

Scott Collis

unread,
Mar 5, 2019, 11:37:04 AM3/5/19
to Mariana Scott, Py-ART Users, Hemedinger, Jason Alexander

Hey Mariana,

We have all kinds of issues with basemap at the moment.

Are you using basemap for radial or grid displays?

 

If the latter I highly encourage you to use X-array and cartopy. Cc-ing in Jason who has recently done some X-Array work for our mapped moments.. He can help. If radial plots, would suggest now is the time to explore cartopy. MPL end of life is coming up quick

--
You received this message because you are subscribed to the Google Groups "Py-ART Users" group.
To unsubscribe from this group and stop receiving emails from it, send an email to pyart-users...@googlegroups.com.
For more options, visit https://groups.google.com/d/optout.

Mahdi Shadkam-Farrokhi

unread,
Jul 26, 2019, 1:46:16 AM7/26/19
to Py-ART Users
Finally, a solution that worked!

Also, the location to add the line 

os.environ['PROJ_LIB'] = ‘/PATH_TO_ANANCONDA_ENV/share/proj/'

is in ...\Anaconda3\Lib\site-packages\mpl_toolkits\basemap\__init__.py
Should be around line 155 and looks like this:


basemap.PNG


Notice I had to change the path mentioned in the post to Library/share. This was the only way I could get it to work since the 'epsg' file is also there (line 159).

I tried a bunch of stuff before this, including adding a new environment, updating pip, etc. so can't be sure exactly if those things helped.
Reply all
Reply to author
Forward
0 new messages