498 Home Syllabus Schedule Mikecz Home Tutorials

Python 1: Installation and Setup

Why code?

A note on the programs we will use

First a note on the programs we will be using:

So: Python is the programming language we will use, Spyder is the interface that will allow us to interact with Python, and Miniconda is the management system that will make it easier to install and work with any additional packages we may need to use.

Anaconda vs. Miniconda

While I suggest most of you install Miniconda, if you think you might go deeper into Python programming after the class is over and you have the space on your computer to install 3 GB of programs, you may want to install the full Anaconda package.

More information is below. (From the documentation)

Choose Anaconda if you:

- Are new to conda or Python
- Like the convenience of having Python and over 150 scientific packages automatically installed at once
- Have the time and disk space (a few minutes and 3 GB), and/or
- Don’t want to install each of the packages you want to use individually.

Choose Miniconda if you:

- Do not mind installing each of the packages you want to use individually.
- Do not have time or disk space to install over 150 packages at once, and/or
- Just want fast access to Python and the conda commands, and wish to sort out the other programs later.

Install Anaconda or Miniconda:

  1. check if Python is installed
    1. open your terminal or command line (for more info on using the terminal in Windows or Mac click on these links).
    2. check if Python is installed, type:

      
      ##for Mac:
      which python
      
      ##for Windows:
      where python
      ##or
      python --version
      
  2. if not installed, Follow directions for installing Miniconda here (Mac) and here (all - Mac/Windows/Linux)..

  3. Open Spyder (type “which spyder” in the Mac terminal or “where spyder” in the Windows terminal to find out where it is).

  4. Place Spyder in your start menu or taskbar so that you can easily find it next time.

Spyder in your start menu
Spyder in your start menu

Write your first program in Python

  1. Create a folder on your computer where you will save all your Python work for this class. It is recommended to not use any spaces in folder names and not to bury it too deep in your computer. (i.e. “C:/Users/yourName/Documents/Python” not “C:/Users/yourName/Documents/2019/Classes/498/ComputerStuff/Python”)
  2. In the editor window, type in the following: (link: os package)

    
    # hashtags represent comments. These are for human eyes only. The computer will not read these.
    
    ## first import the package "os," which will allow us to move between different folders on our computers.
    import os 
    
    ## set the "working directory": the folder you will be using.
    os.chdir([path where your folder is located]) ##i.e. "C:/Users/yourName/498/Python" (include quotes)
    
    print("Hello World!")
    

Save)

  1. Press the green arrow at the top of Spyder to run your first program. –>

Congrats, you have written your first program!

Installation tips??

Working in the console