Data
Data for this lesson is provided by Santa Barbara Coastal, Long Term Ecological Research site. SBC LTER is based at the University of California, Santa Barbara (UCSB) Marine Science Institute. There, they maintain and support research on long-term ecological phenomena; their principal study domain is the northern portion of the Southern California Bight. You may also read more about the greater Long Term Ecological Research Network.
Please download the SBC LTER data files as a zip. This link will give you everything in a compressed file. You will need to unzip this file after downloading it. Please do the same for the second set of teaching data files.
We recommend making a folder on your desktop called “april-2022-python”. Inside of this folder, please keep the data files in another folder called “data”. If you follow these steps, you will have a folder called “april-2022-python”. Inside of april 2022 python, you will have a folder called “data”. Inside of the data folder, is the data files you downloaded from the link above.
Installing Python using Anaconda
Python is a popular language for scientific computing, and great for general-purpose programming as well. Installing all of the scientific packages we use in the lesson individually can be a bit cumbersome, and therefore recommend the all-in-one installer Anaconda.
Regardless of how you choose to install it, please make sure you install Python version 3.x.
If applicable: please log out of any drives on your device before installing the software. (e.g. OneDrive, BoxDrop, etc.)
Installing Anaconda
- Open https://www.anaconda.com/products/individual in your web browser.
- Download the Anaconda Python 3 installer for Windows.
- Double-click the executable and install Python 3 using the recommended settings. Make sure that Register Anaconda as my default Python 3.x option is checked – it should be in the latest version of Anaconda.
-
Verify the installation: click Start, search and select
Anaconda Prompt
from the menu. A window should pop up where you can now type commands such as checking your Conda installation with:conda --help
Video Tutorial
- Visit https://www.anaconda.com/products/individual in your web browser.
- Download the Anaconda Python 3 installer for macOS.
These instructions assume that you use the graphical installer
.pkg
file. - Follow the Anaconda Python 3 installation instructions. Make sure that the install location is set to “Install only for me” so Anaconda will install its files locally, relative to your home directory. Installing the software for all users tends to create problems in the long run and should be avoided.
-
Verify the installation: click the Launchpad icon in the Dock, type Terminal in the search field, then click Terminal. A window should pop up where you can now type commands such as checking your conda installation with:
conda --help
Video Tutorial
Note that the following installation steps require you to work from the terminal (shell). If you run into any difficulties, please request help before the workshop begins.
- Open https://www.anaconda.com/products/individual in your web browser.
- Download the Anaconda Python 3 installer for Linux.
- Install Anaconda using all of the defaults for installation.
- Open a terminal window.
- Navigate to the folder where you downloaded the installer.
- Type
bash Anaconda3-
and press Tab. The name of the file you just downloaded should appear. - Press Return
- Follow the text-only prompts. When the license agreement appears (a colon
will be present at the bottom of the screen) press Spacebar until you see the
bottom of the text. Type
yes
and press Return to approve the license. Press Return again to approve the default location for the files. Typeyes
and press Return to prepend Anaconda to yourPATH
(this makes the Anaconda distribution your user’s default Python).
-
Verify the installation: this depends a bit on your Linux distribution, but often you will have an Applications listing in which you can select a Terminal icon you can click. A window should pop up where you can now type commands such as checking your conda installation with:
conda --help
Required Python Packages
The following are packages needed for this workshop:
All packages apart from plotnine
will have automatically been installed with Anaconda
and we can use Anaconda as a package manager to install the missing plotnine
package:
You need to open up a Terminal, if you are using Mac OSX, or Linux (see instructions above),
or launch an anaconda-promt, if you are using Windows. In your terminal window type the following:
conda install -y -c conda-forge plotnine
This will then install the latest version of plotnine into your conda environment.
Required packages: Miniconda
Miniconda is a lightweight version of Anaconda. If you install Miniconda instead of Anaconda, you need to install required packages manually in the following way:
conda install -y numpy pandas matplotlib jupyter
conda install -c conda-forge plotnine
(Alternative) Installing required packages with environment file
Download the environment.yml file by right-clicking the link and selecting save as. In the directory where you downloaded the environment.yml file run:
conda env create -f environment.yml
Activate the new environment with:
conda activate python-ecology-lesson
You can deactivate the environment with:
conda deactivate
Launch a Jupyter Lab
After installing either Anaconda or Miniconda and the workshop packages, launch JupyterLab. You can launch JupyterLab through Anaconda Navigator, or by typing this command from the terminal:
jupyter lab
JupyterLab should open automatically in your browser. If it does not or you wish to use a different browser, open this link: http://localhost:8888/lab.