jakevdp / PythonDataScienceHandbook

Python Data Science Handbook: full text in Jupyter Notebooks
http://jakevdp.github.io/PythonDataScienceHandbook
MIT License
43.17k stars 17.93k forks source link

Problem when installing Basemap #219

Open Hermes-MG opened 4 years ago

Hermes-MG commented 4 years ago

When I install basemap I obtained an already done code

Requirement already satisfied: basemap in c:\users\paisa\anaconda3\lib\site-packages (1.2.1) Requirement already satisfied: pyproj>=1.9.3 in c:\users\paisa\anaconda3\lib\site-packages (from basemap) (1.9.6) Requirement already satisfied: matplotlib!=3.0.1,>=1.0.0 in c:\users\paisa\anaconda3\lib\site-packages (from basemap) (3.2.0) Requirement already satisfied: six in c:\users\paisa\anaconda3\lib\site-packages (from basemap) (1.12.0) Requirement already satisfied: pyshp>=1.2.0 in c:\users\paisa\anaconda3\lib\site-packages (from basemap) (2.1.0) Requirement already satisfied: numpy>=1.2.1 in c:\users\paisa\anaconda3\lib\site-packages (from basemap) (1.18.1) Requirement already satisfied: python-dateutil>=2.1 in c:\users\paisa\anaconda3\lib\site-packages (from matplotlib!=3.0.1,>=1.0.0->basemap) (2.8.0) Requirement already satisfied: kiwisolver>=1.0.1 in c:\users\paisa\anaconda3\lib\site-packages (from matplotlib!=3.0.1,>=1.0.0->basemap) (1.1.0) Requirement already satisfied: pyparsing!=2.0.4,!=2.1.2,!=2.1.6,>=2.0.1 in c:\users\paisa\anaconda3\lib\site-packages (from matplotlib!=3.0.1,>=1.0.0->basemap) (2.4.2) Requirement already satisfied: cycler>=0.10 in c:\users\paisa\anaconda3\lib\site-packages (from matplotlib!=3.0.1,>=1.0.0->basemap) (0.10.0) Requirement already satisfied: setuptools in c:\users\paisa\anaconda3\lib\site-packages (from kiwisolver>=1.0.1->matplotlib!=3.0.1,>=1.0.0->basemap) (46.0.0)

But when I want to import it I obtain the following error

KeyError Traceback (most recent call last)

in 2 import numpy as np 3 import matplotlib.pyplot as plt ----> 4 from mpl_toolkits.basemap import Basemap ~\Anaconda3\lib\site-packages\mpl_toolkits\basemap\__init__.py in 150 151 # create dictionary that maps epsg codes to Basemap kwargs. --> 152 pyproj_datadir = os.environ['PROJ_LIB'] 153 epsgf = open(os.path.join(pyproj_datadir,'epsg')) 154 epsg_dict={} ~\Anaconda3\lib\os.py in __getitem__(self, key) 676 except KeyError: 677 # raise KeyError with the original key value --> 678 raise KeyError(key) from None 679 return self.decodevalue(value) 680 KeyError: 'PROJ_LIB' I have done some google research and apparently there is a problem with the libraires version. How can I fix it?
Emonsayhi commented 4 years ago

Try run these codes first

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
Hermes-MG commented 4 years ago

Thank you Steven. It did not work. It is fixed by the following code:


import os os.environ['PROJ_LIB'] = r'c:\Users\Paisa\anaconda3\Library\share'


I suspect that is nearly identical to yours..., but indeed I don't know. I am not a computer person..😏 Thanks again


De: Steven.Meng notifications@github.com Enviado: jueves, 26 de marzo de 2020 3:43 Para: jakevdp/PythonDataScienceHandbook PythonDataScienceHandbook@noreply.github.com Cc: Hermes-MG paisanohermes@hotmail.com; Author author@noreply.github.com Asunto: Re: [jakevdp/PythonDataScienceHandbook] Problem when installing Basemap (#219)

Try run these codes first

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

— You are receiving this because you authored the thread. Reply to this email directly, view it on GitHubhttps://nam12.safelinks.protection.outlook.com/?url=https%3A%2F%2Fgithub.com%2Fjakevdp%2FPythonDataScienceHandbook%2Fissues%2F219%23issuecomment-604258746&data=02%7C01%7C%7Cedff2dd66afd4ba80a5d08d7d15110f0%7C84df9e7fe9f640afb435aaaaaaaaaaaa%7C1%7C0%7C637208018415391998&sdata=%2FoPDdeJNbpB7HbXk%2Fed0lOuJtMgA7Zd5IqyJxUQJtJI%3D&reserved=0, or unsubscribehttps://nam12.safelinks.protection.outlook.com/?url=https%3A%2F%2Fgithub.com%2Fnotifications%2Funsubscribe-auth%2FAJ5ATR4K4V3TP6WAJS77FBTRJL2S7ANCNFSM4LN46EMQ&data=02%7C01%7C%7Cedff2dd66afd4ba80a5d08d7d15110f0%7C84df9e7fe9f640afb435aaaaaaaaaaaa%7C1%7C0%7C637208018415391998&sdata=8v6RpbMUr2Gb1SCwJi8t46P15t5ydmIBmrIVzwzppV8%3D&reserved=0.