To install Python, JupyterLab, and the packages for the Environmental Data Science course read the instructions below or watch the video:
In this course we will use Python with Jupyterlab, which is an open-source interactive development environment (IDE) that facilitates data science and scientific computing in Python through a web-based interface.
You can install Python using different methods:
This tutorial shows you how to:
You can easily install Python through Minoconda from Minconda webpage. You can find more information at GeoPython - Installing Python.
After the installation is complete, from Windows Star Menu, open Anaconda Prompt(Miniconda3) and type:
python --version
This will return to you the Python version that you have installed (e.g., Python 3.11.5).
Note: Make sure you that you have a 64-bit system. If you do not know: Use the search icon near “Start Menu” and search for “About” that will take you to”Settings”: “About” where you can know if you have a 32-bit or 64-bit processor.
You do not want to use Python in a black screen, so you need to install a graphical user interface(GUI). For programming languages, a GUI is called interactive development environment (IDE). The IDE that we will use for this course is Jupyterlab, which is an open-source IDE for Python, Julia, R, MATLAB/Octave, and few other programming languages.
In Python, we generally use pip
or conda
for installation. For details about JupyterLab installation, check the JupyterLab documentation, or follow these steps:
From the Windows Start menum, search for and open your Anaconda Prompt(Miniconda3), and install JupyterLab with pip by running this command:
pip install jupyterlab
Alternatively, you can install JupyterLab with conda with conda-forge channel by running this command:
conda install -c conda-forge jupyterlab
Once installed, launch JupyterLab with:
jupyter lab
Each time you use JupterLab, you do not want to open an Anaconda Prompt(Miniconda3) and type jupyter lab
. You can create a shortcut to automatically lunch JupyterLab following these steps.
Create Anaconda Prompt Shortcut:
jupyter lab
which will lunch JupyterLab.Customize Anaconda Prompt Shortcut:
& jupyter lab && exit
At my machine the content of the “Target” cell now looks something like this:
%windir%\System32\cmd.exe "/K" C:\Users\username\AppData\Local\miniconda3\Scripts\activate.bat C:\Users\username\AppData\Local\miniconda3 & jupyter lab && exit
If this is unclear, check this YouTube video
In case you want your icon to look nice
.ico
.From the miniconda terminal install these libraries one by one. You can install them now or before each lesson.
pip install pyarrow pandas matplotlib numpy lckr_jupyterlab_variableinspector
pip install xarray netCDF4 cartopy
pip install scipy seaborn statsmodels scikit-learn shap tensorflow
pip install earthengine-api geemap ipywidgets
pip install copernicusmarine dataretrieval requests
Note: dataretrieval
retrieves the major data types of USGS hydrology data that are available on the Web, as well as data from the Water Quality Portal (WQP), which currently houses water quality data from the EPA, USDA and USGS. Direct USGS data is obtained from a service called the National Water Information System (NWIS).
Jupyter AI facilitates AI coding assistance by bring language models such as ChatGPT to your Jupyter environment. You first need to have an API key for your language model to work. For example, if you want to use ChatGPT, check this file for OpenAI API key. Also, the installation time can be long, so you need to be patient.
To install Jupyter-AI with dependencies for all supported language models (not recommended):
pip install jupyter-ai[all]
To install Jupyter-AI wit with dependencies of selected model providers such as OpenAI, e.g., ChatGPT and Google, e.g., Gemini (recommended):
pip install jupyter-ai langchain-openai langchain-google-genai
The above comand provides two examples, but you can check the model provider table for information on supported providers and their dependencies.
Note: Jupyter AI may not work for the current python or JupyterLab version. You might need to upgrade/downgrade your python version to meet the version requirement. Installing Jupyter AI can be time consuming and tricky, so you can skip it and use language models (e.g. ChatGPT) outside the Jupyter environment. If you want to give it a try, before you start you need to check jupyter-ai documentation for requirements and instructions.
pip install geopandas contextily shapely adjustText
pip install windrose
Note: This will not replace a GIS software such as ArcGIS Pro or QMap, but it is useful for integrating GIS maps in your workflow.
Sometime you need to update your Python version, which you can do by creating a new environment. Here is how to upgrade from Python 3.11 to 3.12:
conda create -n py312 python=3.12
Activate the new environment to take priority when you start Python
conda activate py312
You can check your environments:
conda info --envs
Then you can install everything at once, but creating a requirements.txt
file with the following content:
jupyterlab
pyarrow
pandas
matplotlib
numpy
lckr_jupyterlab_variableinspector
xarray
netCDF4
cartopy
scipy
seaborn
statsmodels
scikit-learn
shap
tensorflow
earthengine-api
geemap
copernicusmarine
dataretrieval
requests
jupyter-ai
langchain-openai
langchain-google-genai
geopandas
contextily
shapely
adjustText
windrose
Then install everything using:
pip install -r requirements.txt
Now you have JupyterLab and Python installed , you can start with these: