1. Install Python IDLE 'PyCharm Community Edition'

  • After installation IDLE, Launch PyCharm and Create New Project.
  • Next, Set Python environment for Python scripts execution.

Open IDLE -> Go to 'File' -> Select 'Settings' -> Go to 'Project' -> Select 'Project Interpreter' -> Browse and provide anaconda python exe path. (Mostly location of python exe is at user profile, Ex: C:\Users\<User_Name>\Anaconda2\python.exe [C:\Users\Dinesh\Anaconda2\python.exe])

OR Install Python anaconda (Windows, OS and Linux)

Just follow the instructions on:

https://www.anaconda.com/download/ 

Note you may need to activate your conda version.

A way to do this is:

source MY_CONDA_DIR/etc/profile.d/conda.sh

conda activate 

2. Use Conda to manage installation of required Python packages 

2.1 netcdf

This package manage and read ncdf data

https://unidata.github.io/netcdf4-python/netCDF4/index.html

  • Install from conda:

conda install netcdf4 

2.2 xarray / matplotlib / numpy

These packages to allow numerical operations / handle arrays

https://www.numpy.org/  

http://xarray.pydata.org/en/stable/ 

https://matplotlib.org/

  • Install from conda:

conda install numpy

conda install xarray 

conda install matplotlib 

2.3 pyhdf

This package read and manage hdf files

https://hdfeos.org/software/pyhdf.php

  • Install from conda run one of the following:

conda install -c conda-forge pyhdf 
conda install -c conda-forge/label/gcc7 pyhdf 
conda install -c conda-forge/label/cf201901 pyhdf 

2.4 basemap

This package integrate matplotlib to manage maps

https://matplotlib.org/basemap/

  • Install from conda run one of the following:

conda install basemap

  • If this does not work, try the following commands:

conda install -c conda-forge basemap

  • After installing python package if you get following error:
test_python.py:None (test_python.py) test_python.py:20: in <module> from mpl_toolkits.basemap 
import Basemap, cm
  C:\Users\USER\Anaconda2\lib\site-packages\mpl_toolkits\basemap\__init__.py:155                       :in <module>
  C:\Users\USER\Anaconda2\lib\site-packages\mpl_toolkits\basemap\__init__.py:155                       :in <module>
  pyproj_datadir = os.environ['PROJ_LIB']
  C:\Users\USER\Anaconda2\lib\os.py:425: in __getitem__return self.data [key.upper()]
  E   KeyError: 'PROJ_LIB' collected 0 items / 1 errors
  • Here is a way to resolve the issue:

Add the following two lines before importing 'Basemap' to python script. Refer to below figure

         import os
         os.environ['PROJ_LIB'] = r'C:\Users\Dinesh\Anaconda2\Library\share'

 

2.5 hdf4 and hdf5

This package handle hdf4 and hdf5 files

  • Install from conda run one of the following:

  conda install -c conda-forge hdf4

  conda install -c conda-forge hdf5

2.5 Jupyter notebook

You may be now ready to play with test Python scripts undet jupyter notebook. This comes with anaconda and in principle you may be all set. 

https://jupyter.org/

Here you will also find information on how to install it, if needed

  • To launch Jupyter:

  Jupyter-Notebook

From the browser, open the scripts and run them step-by-step.

Last modified: Monday, 21 October 2019, 1:31 PM