lesson 2: preparation

16
1 Lesson 2: Preparation Using the EartH2Observe data portal to analyse drought indicators 1 Preface This is a stepbystep tutorial that will help you install all the software required for the further lessons in the eCourse “Using the EartH2Observe data portal to analyse drought indicators”. It is important that all software is installed and ready to use prior to continuing with this course, in order to be able to fully undertake all the steps in the course. This stepbystep guide in making the necessary preparations is specifically written for Windows operating systems. For Lesson 4 it is required to work with python scripts. The version of Python we will use in this session is the Anaconda distribution, which includes the most essential python packages, allows for easy installation of new packages and is thus used throughout the session. The prerequisites for taking part in the special session are that users have the following (installed): A google account Anaconda Navigator 2.7 2 Python packages: NetCDF4 mpl_toolkits.basemap In this guide we provide a detailed, stepbystep procedure to establish a google account and install the required version of Python. Table of Contents 1 Preface 1 2 Setting up a Google Account 2 3 Anaconda Navigator 3 3.1 Download and Install Anaconda Navigator 3 3.2 Test Correct Installation of Anaconda Navigator 8 3.3 Add the Python Path in the Environment Variables 8 3.4 Test the Environment Variables Path 11 4 Python Packages 12 4.1 Install netcdf4 12 4.2 Install mpl_toolkits.basemap 12 4.3 Test Correct Installation of the Python Packages 14

Upload: others

Post on 28-Mar-2022

5 views

Category:

Documents


0 download

TRANSCRIPT

Microsoft Word - Lesson 2 - Using the E2O data for drought analysis - preparationdrought indicators   
1 Preface 
This is a stepbystep tutorial that will help you install all the software required for the further lessons 
in the eCourse “Using the EartH2Observe data portal to analyse drought  indicators”. It  is  important 
that all software is installed and ready to use prior to continuing with this course, in order to be able 
to  fully  undertake  all  the  steps  in  the  course.  This  stepbystep  guide  in making  the  necessary 
preparations is specifically written for Windows operating systems. 
 
For  Lesson 4  it  is  required  to work with python  scripts. The  version of Python we will use  in  this 
session  is the Anaconda distribution, which  includes the most essential python packages, allows for 
 
The prerequisites for taking part in the special session are that users have the following (installed): 
A google account 
Anaconda Navigator 2.7 
2 Python packages: 
 
In this guide we provide a detailed, stepbystep procedure to establish a google account and install 
the required version of Python.  
 
2  Setting up a Google Account  2 
3  Anaconda Navigator  3 
3.2  Test Correct Installation of Anaconda Navigator  8 
3.3  Add the Python Path in the Environment Variables  8 
3.4  Test the Environment Variables Path  11 
4  Python Packages  12 
4.1  Install netcdf4  12 
4.2  Install mpl_toolkits.basemap  12 
2   
2 Setting up a Google Account 
For the first part of the session, you will need to have a google account. If you already have a Google 
account you can skip this step.  
If you do not already have one, open an  internet browser, such as Google Chrome, Mozilla Firefox, 
Internet Explorer or Safari. Go  to accounts.google.com/SignUp and  fill  in all  the  fields on the right
hand side.  
3.1  Download and Install Anaconda Navigator 
For the second part of the workshop, we will work with existing python scripts. In order to do so, you 
will  need  Anaconda Navigator  as well  as  two  additional  packages  installed  and working  on  your 
computer. 
NOTE:  Please ensure that there are no existing versions of python on your computer, as this will 
result in conflicts during the installation and the workshop. 
Step 1:  Open an internet browser and go to www.anaconda.com/download/  
Step 2:  Download the version Python 2.7, for Windows, MacOS or Linux, depending on your 
operating system. Choose the 64Bit or 32Bit version according to your own computer. This 
does not affect the rest of this tutorial. 
 
   
 
 
 
5   
 
 
Step 6:     Select the destination folder using Browse (such as the Programe_Files folder as is used 
in this tutorial) and click next. 
 
6   
NOTE:  Make sure there are no spaces in the folder path, python will give a warning otherwise. 
 
 
Step 7:  For the Advanced Installation Options, just select the default one Register Anaconda as my 
default Python 2.7 and click Install. This may take a while. 
NOTE:  We assume you do not have admin access on your computer. If you do have admin access, 
you can also check the box for Add Anaconda to my PATH environment variable. If you do not check 
this box, we will add the path after the installation, in Section  
3.3  Add the Python Path in the Environment Variables. 
 
   
7   
 
 
 
 
   
3.2  Test Correct Installation of Anaconda Navigator 
Step 9:  Now that Anaconda Navigator is installed, we will check if it is working using the Anaconda 
Prompt. Go to start, then type Anaconda Prompt and press enter. 
Step 10:  Type python version and press enter. You will now see the version of Python and 
 
 
3.3  Add the Python Path in the Environment Variables 
So far we have only used Anaconda Prompt to see if python was working. Now we will manually add 
the paths for both Anaconda and Python, so we can use it in the command prompt as well.  
NOTE:  This part is only necessary if you did not select the Add Anaconda to my PATH 
environment variable in Step 7. 
Step 11:  Type in your Anaconda Prompt where conda and press enter. This will show you the folder 
path of where anaconda is installed. In this tutorial, the path is: 
C:\Program_Files\Anaconda2\Scripts 
  Type in your Anaconda Prompt where python and press enter. In this tutorial, the path to 
python is: C:\Program_Files\Anaconda2 
 
Name
Name
Name
Name
Name
9   
Step 12:  Now you will add your paths to anaconda and python manually. Go to your computer (in 
   
 
 
   
 
 
 
Step 16:  At the field Variable name, type PATH  
  At the field Variable value, type the path to the conda.exe file;path to the python.exe file 
 
 
Step 17:  Click OK at all fields that are still open (New System Variable, Environment Variables, and 
System Properties) to verify all changes. 
 
 
3.4  Test the Environment Variables Path  
Now that the paths to Anaconda and Python are manually added, we will check if the computer can 
indeed find the paths using the command prompt. 
Step 18:  Open a Command Prompt: 
Go to Start  
Type cmd.exe  
Press enter or click on the Command Prompt to open it 
Step 19:  Type python version and press enter 
 
 
As you can see, the version for python is now shown from the command prompt as well . The 
computer can thus find the paths to Anaconda and Python correctly.    
Name 
Name 
Name 
12   
4 Python Packages 
Now that you successfully installed Anaconda Navigator and Python 2.7, we will install two packages 
that will be used  in  the workshop as well. These packages are netCDF4 and mpl_toolkits.basemap. 
You will see that this is relatively easy due to the successful instalment of Anaconda Navigator. 
 4.1  Install netcdf4  
Step 20:  Open a command prompt. Go to Start and type cmd.exe, and press enter or click on the 
Command Prompt to open it. 
Step 21:  Type conda install netcdf4 
 
 
 
4.2  Install mpl_toolkits.basemap  
Step 23:  First download the geos3.3.5 package by typing: conda install geos 
 
   
 
  And download the file basemap1.1.0cp27cp27mwin_amd64.whl 
Step 26:  Depending on the settings of your web browser, the file basemap1.1.0cp27cp27m
win_amd64.whl may be downloaded to a specific download directory. In this case, you can 
either keep the file in the downloads directory, or move the file to the directory where the 
Python packages are installed, in this tutorial this would be: 
C:\Program_Files\Anaconda2\pkgs 
NOTE:  The directory of where the basemap1.1.0cp27cp27mwin_amd64.whl file is located is 
required for step 29. 
Step 27:  Change the directory in the command prompt to the same folder, type:  
cd C:\Your_path\Anaconda2\pkgs 
  In this tutorial, the path is C:\Program_Files, so it would be: 
cd C:\Program_Files\Anaconda2\pkgs 
 
Step 28:  Install pyproj. In order to do so, type in the command prompt:  
conda install pyproj 
 
   
Step 29:  Install mpl_toolkits.basemap by typing in the command prompt: 
pip install basemap1.1.0cp27cp27mwin_amd64.whl 
Note that depending on the settings of your web browser, the file basemap1.1.0cp27cp27m
win_amd64.whl may be downloaded to a specific download directory. In this case you can either 
move the file to the directory you are working in, or add the full path name to the above comment. If 
for example the download directory is d:\downloads then the above command should be: 
  pip install d:\downloads\basemap1.1.0cp27cp27mwin_amd64.whl 
 
   
 
 
 
4.3  Test Correct Installation of the Python Packages 
Step 31:  Open a new command prompt (again, click on start, type cmd, press enter) 
Step 32:  Type spyder and press enter. Now Spyder, which is automatically installed with Anaconda 
Navigator, will be automatically opened. 
 
   
 
 
Step 34:  Test if the netCDF4 package is working, type in the IPython console (at the bottom right) : 
import netCDF4 as nc 
Step 35:  Test if the mpl_toolkits.basemap package is working, type: 
  from mpl_toolkits.basemap import Basemap 
   
If  there  are  no  error  messages,  you  have  successfully  installed  Anaconda,  Python  2.7,  and  the 
packages netCDF4 and mpl_toolkits.basemap.  
 
Note that in some cases difficulties may be experienced with the installation of Basemap. If this is the 
case, please try and use forums on internet to find solutions, as there are several forums available.  
If  it proves  impossible then the use of Basemap can be avoided, though  the maps developed  in the 
tutorial may not be as elegant as with Basemap.