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
This seems to be a common issue. There are several bug reports about it
I had run into this error myself, and for me the solution was to uninstall basemap 1.2, then install basemap 1.1 from an old wheel file I still had lying around and then install basemap 1.2 again. I honestly have no idea why that worked though.
Also from those issues above there are all kinds of other solutions that people have reported to work for them. Hopefully one of them fits here as well.
Proj4 easy solution to fix on pycharm is goto setting-> project interpreter -> + -> write proj4 in the search field and install.
Following mewahl's comment I've added to my .bashrc (I use bash):
export PROJ_LIB=/path/to/your/instalation/of/anaconda/share/proj/
and now basemap (and others work).
I was not able to solve this problem but I was able to find an alternate, use CartoPy. basemap is being maintained for python 2.7 users. CartoPy is a better alternative
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'
The answer is from Github and it worked for me.
import os
import conda
conda_file_dir = conda.__file__
conda_dir = conda_file_dir.split('lib')[0]
proj_lib = os.path.join(os.path.join(conda_dir, 'share'), 'proj')
os.environ["PROJ_LIB"] = proj_lib
from mpl_toolkits.basemap import Basemap