Basemap import error in PyCharm — KeyError: 'PROJ_LIB'

前端 未结 9 600
生来不讨喜
生来不讨喜 2020-11-30 02:27

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 T

9条回答
  •  南笙
    南笙 (楼主)
    2020-11-30 03:08

    You have to set the path of Proj lib as in newer version , this path has been replaced. Write below two lines of code before importing matplot_toolkits

      ### For Window's Users
          import os
          os.environ['PROJ_LIB'] = r'C:\Users\XXXXX\Anaconda3\pkgs\proj4-5.2.0- 
          ha925a31_1\Library\share'
    

    To find the path of Proj_lib , just search epsg and then copy this epsg file location and put in proj_lib . Your Problem will be solved.

      ### For Linux's Users
      import os
      os.environ['PROJ_LIB'] = r'/home/XXXXXX/anaconda3/pkgs/proj4-5.2.0- 
      he6710b0_1/share/proj'
    

提交回复
热议问题