Installation of basemap or netCDF package on your computer (using Anaconda)

Python is an open-source, multi-purpose language. Some useful packages developed by enthusiastic users, or official packages with very specific functions may not be installed under the default setting. It is therefore of practial purpose to learn how to install these additional packges on your own.

Here we will introduce how to install NetCDF4 and Basemap packages using Anaconda. These two packages are available on our study server, but some of you may not have them installed in the python system on your computer (check this by "import netCDF4" or "import mpl_toolkits.basemap"). Following through the steps below:

PS. In the following images we use "basemap" as example. Installing netCDF4 is very similar, just change "basemap" to "netCDF4".

Method 1: using command line

  • Activate the command line window by clicking "Anaconda Prompt".
  • Then enter "conda install -c conda-forge basemap" or "conda install -c conda-forge netcdf4" to start the installation. If a question shown up with [y/n], enter y to proceed.

Method 2: using Anaconda Navigator

Anaconda Navigator is a graphic interface to manage the python packages intalled on your computer.

  • You need to first add a new "channel", conda-forge, so that Anaconda can find the correct version of netcdf4 or basemap from the internet.

  • Then from the "uninstalled" package list, find "basemap" or "netcdf4" and click "apply" to intall (The new version, basemap_1.1.0, will show up after you click apply).

Finally, activate Python and import netCDF or import mpl_toolkits.basemap If no error mesage then the package was installed successfully.