I tried to use Basemap package to plot a map by PyCharm, but I got something wrong with
from mpl_toolkits.basemap import Basemap`
And the Traceback as followed:
Traceback (most recent call last):
File "/Users/yupeipei/anaconda3/lib/python3.6/site-packages/IPython/core/interactiveshell.py", line 2963, in run_code
exec(code_obj, self.user_global_ns, self.user_ns)
File "<ipython-input-4-0a24a3a77efd>", line 7, in <module>
from mpl_toolkits.basemap import Basemap
File "/Applications/PyCharm.app/Contents/helpers/pydev/_pydev_bundle/pydev_import_hook.py", line 20, in do_import
module = self._system_import(name, *args, **kwargs)
File "/Users/yupeipei/anaconda3/lib/python3.6/site-packages/mpl_toolkits/basemap/__init__.py", line 146, in <module>
pyproj_datadir = os.environ['PROJ_LIB']
File "/Users/yupeipei/anaconda3/lib/python3.6/os.py", line 669, in __ getitem__
raise KeyError(key) from None
KeyError: 'PROJ_LIB'
I'm confused with this error on PyCharm, because the same script is running correctly on Jupyter or Spyder! The environment in PyCharm is ../anaconda3/lib/python3.6 where is same from anaconda.
Has anyone met this error before?
Could anyone can help me to solve this error?
.../site-packages/mpl_toolkits/basemap/__init__.py
to point directly to where the PROJ library was installed, instead of looking for an environment variable. (In my case, the anaconda pyproj package installed the PROJ library at/anaconda/envs/[my env name]/share/proj
-- YMMV.) – Hush