Setting up Python Environment#

When you want to use Python to write scripts and programmes on your own computer, you need to install Python, and possibly some of the many packages for it that provide tools for specific tasks, such as handling GIS data sets. On this page, we present one of the ways to install Python and Python packages. During this tutorial, we will use the conda package management system, and below you will find installation instructions of Anaconda distribution on different operating systems.

Do I need to install Anaconda?

You don’t necessarily need to install Anaconda to complete the assignments. There are alternative options available:

  • Visual Studio Code (VS Code): You can use VS Code as an alternative to Anaconda. Check out detailed tutorial on setting up VS Code, Python, and Git here

  • Google Colab: If you prefer not to install anything locally, you can run all your Python code and markdown tasks interactively in the browser using Google Colab.

Regardless of the platform you choose, ensure you use code versioning and connect your work to GitHub. This is essential for maintaining your project and submitting your assignments correctly.

What is Anaconda?#

Anaconda is a distribution of the Python and R programming languages for scientific computing, that aims to simplify package management with conda environments.

Anaconda offers the easiest way to perform data science and machine learning on a single machine.

Install Anaconda#

This video tutorial covers how to install Anaconda. Follow along to learn how to install Anaconda for the ENGO 645/537 Spatial Data Mining Lab.

Visit the Anaconda website and download Anaconda for your operating system (Windows, macOS, Linux). Choose the version labeled “Download” under the Anaconda Individual Edition. Once the download has finished, double-click the downloaded installer file to start installation. Once the download completes, open the installer. Follow the installation instructions, leaving the default options selected unless you have specific preferences.

Note

Install Anaconda to a directory path that does not contain spaces or unicode characters.

Anaconda installer

Anaconda installer#

Choose the defaul checkbox register Anaconda as your default Python. Don’t check the “add Anaconda to your PATH environment” unless you have or you want to install different versions of python in your system. Otherwise just use the default setting.

Anaconda installer setup

Anaconda installer setup#

Note

If you encounter issues during installation, temporarily disable your anti-virus software during install, then re-enable it after the installation concludes.

After the installation is complete, you’ll find Anaconda Navigator installed on your computer. You can find it in your Start Menu. This is a graphical interface that helps manage Anaconda and its applications.

Successfullyinstalled Anaconda

Successfullyinstalled Anaconda#

Note

Anaconda Navigator is a graphical user interface (GUI) that is automatically installed with Anaconda. Navigator will open if the installation was successful. If Navigator does not open, something went wrong with your installation.

Overview of Anaconda Navigator

Overview of Anaconda Navigator#

JupyterLab#

JupyerLab is an open-source web-based user interface for doing data science. The JupyterLab interface consists of different components such as a file browser, terminal, image viewer, console, text editor, etc.

Jupyter Notebooks (filename extension .ipynb) are documents inside the JupyterLab environment which contain computer code, and rich text elements (figures, links, etc.).

Jupyter Notebooks are perfect for documenting a data science workflow in an interactive format.

Important

While our tutorials primarily utilize Jupyter Lab, we encourage exploration and adaptation. You are free to work in other platforms such as Google Colab or VS Code to interact with .ipynb files.

Remember, regardless of the platform used, for consistency and assessment purposes, all submissions should be in the .ipynb format. Enjoy exploring various environments to enrich your learning experience!

Opening Your First Jupyter Lab#

Find and open Anaconda Navigator. In the Navigator window, locate the “Jupyter Lab” icon and click “Launch.” This will open a new tab or window in your default web browser.

Jupyter Lab

Basic view of JupyterLab#

In the Jupyter Lab interface, click the “+” icon on the left sidebar and select “Notebook” under “Python 3” to create a new notebook. This opens a new tab titled “Untitled.ipynb” where you can start working.

The notebook consists of cells. Click on the first empty cell and change its type to “Code” using the dropdown menu in the toolbar (it defaults to “Code” type). Try entering a simple Python command like print("Hello World!") in the cell.

Running Code Cells:

To execute the code in the cell, press Shift + Enter. You’ll see the output displayed just below the cell.

A Jupyter Notebook open in JupyterLab

A Jupyter Notebook open in JupyterLab#

Markdown Cells:

Create a new cell below the code cell by clicking the “+” icon in the toolbar or pressing B while in command mode (press Esc to enter command mode). Change the cell type to “Markdown” using the dropdown menu in the toolbar. Try entering Markdown syntax, such as # This is a heading or **Bold text**.

A Markdown in Jupyter Notebook

Markdown in Jupyter Notebook#

Save your work by clicking “File” > “Save Notebook” or using the shortcut ctrl + s.

Page summary#

Congratulations! You’ve explored the basics of Jupyter Lab, executed Python code, and experimented with Markdown cells. Jupyter Lab’s interactive environment allows for efficient and intuitive coding, documentation, and data analysis. Continue experimenting with different functionalities to enhance your learning experience!