HI, I faced the same issues last week and experienced several of failed solutions on the internet. But this post works to me like a charm:
For Windows 10 with Anaconda + Python 3.71 (and I’m sure other Python 3 versions and Windows 7/8), you can tell Basemap where Proj4’s “epsg” file is to succeed. I don’t have an “environment” or whatever because it’s too much work to figure out - so I didn’t have an anaconda\share\proj area (as far as I could discern why I didn’t have it).
But, what Basemap wants is the file “epsg”, search the Anaconda directory for it with Windows Explorer. If it doesn’t find it, install Proj4 by opening the “Anaconda Prompt” and typing in:
conda install -c conda-forge proj4
If it finds it, it should be in something like:
C:\Utilities\Python\Anaconda\Library\Share (it’s where mine was, as well as \pkgs\ places where I guess it puts the package itself - and those can work too if need be, I used them at first, but the library one should work through updates better (maybe)).
Use the following code before importing Basemap and it’ll work. Sets the environment variable PROJ_LIB to wherever epsg is and then Basemap can be happy.
os.environ["PROJ_LIB"] = "C:\\Utilities\\Python\\Anaconda\\Library\\share"; #fixr
from mpl_toolkits.basemap import Basemap
As a nice bonus, to get hi-res data of Basemap, which Anaconda doesn’t include in the Basemap install to start, type into “Anaconda Prompt”:
conda install -c conda-forge basemap-data-hires