Python and Jupyter Installation Instructions

This is a set of notes guiding you through the installation of a set of tools that will allow you to build and study Python code in your computer. Among many possible options and combinations, this guide focuses on Miniconda and Visual Studio Code, which have pretty straight forward installation, a rich set of features, and offer almost identical experience in Windows, Mac or Linux.

The first thing is to check if your system already has an older version of Python installed. Open a command line interface and type python. In windows you can type cmd in the Search box. In a Mac or Linux computer, a Terminal window will do the same. Mac OS, and sometimes Linux come with a default, probably very old, installation of Python that is required for proper functioning of the system. Otherwise it is easier and cleaner to remove all other versions of Python and start from a clean slate.

In [1]:
from IPython.display import YouTubeVideo
PL=["VB9eyupxrrk","jKUUnSQ-bV8","Gx7ON77BWn0","Zy61GEGI--8","-YFa8d5nh2w","8trDLzfnYj0"]

Download Miniconda

Miniconda is a slim down version of Anaconda. Anaconda is a professional software system that helps install and maintain a full stack of Python and required packages. Anaconda is very popular among Data Scientists because it offers a one-stop no-worries solution. The video below shows how to download Miniconda on a Windows computer. The process for Mac and Linux is identical.

In [13]:
YouTubeVideo(PL[0])
Out[13]:

Install Miniconda

Installation of Miniconda is straight forward. You only need to pay attention to the location of installation. Everything needed and added to your computer is contained in this directory. If you need to remove Miniconda, you only need to delete this directory.

In [8]:
YouTubeVideo(PL[1])
Out[8]:

Setting up Miniconda

Verify that Minincoda is working by typing cmd in the Search box. A new option should appear in addition to the regular 'Command Prompt' named 'Anaconda Prompt'. This is a modified CLI that known about the newly install Miniconda. If you open this, you will note that the prompt start with (base) indicating that the base Miniconda environment was loaded. The Terminal window in Mac or Linux should show the same modified prompt. Starting python will display a recent version of Python and the prompt >>>. To exit Python and go back to the shell press Ctr-Z in Windows or Ctr-D in Mac or Linux, or type exit(). Note the parentheses that shows execution of a function with no arguments, as opposed to typing just exit, which asks for a variable named exit, which of course does not exist.

Miniconda comes only with the bare minimum. We install the packages that we know we will need by typing the CLI command conda install numpy, to install the numpy package. Do the same to install matplotlib and jupyter. You can search available packages with conda search and the name of what are you looking for,

In [14]:
YouTubeVideo(PL[2])
Out[14]:

Download Visual Studio Code

Everything needed is ready to start programming in Python now directly from the CLI. For larger projects and a more productive setting, a programming editor helps with typing programs, highlighting syntax and help. The video below shows how to download Visual Studio Code from Microsoft.

In [10]:
YouTubeVideo(PL[3])
Out[10]:

Install and setup Visual Studio Code

After straight forward installation, open VS Code and create a new file with some Python code. If you save it as a .py file, VS Code will offer to install the Python Extension. After installing this extension, VS Code will discover your Miniconda installation and offer to link the extension with it.

VS Code comes with an integrated Terminal panel in Windows, Mac and Linux. This is a very useful feature because it allows to develop and run code all within the same environment. There is no need to switch to a CLI back and forth, to edit the code and to run it. However, the default shell for VS Code in Windows is set to PowerShell, which does not work well with Miniconda (or Anaconda in general). The video shows how to switch the default terminal to cmd.

In [11]:
YouTubeVideo(PL[4])
Out[11]:

Run Python from Command Line Interface (Windows)

This video demonstrates a simple Python programming session from a CLI, creating a working space and running a code that was edited with an editor, VS Code for example. Creating graphics should work too from CLI. The experience in Mac and Linux is very similar, although you probably noted some essential differences. Different parts of the file path are separated by \' in Windows, whereas in Mac and Linux we use/`. The files are copied with 'copy' in Windows and with 'cp' in Mac and Linux. Have you noticed other differences?

Having installed Jupyter with conda install command, you can start a Jupyter session from the current directory with jupyter notebook. This command starts a web server, opens the frontend in the browser and connects it to a kernel. The command jupyter-lab starts the newest (and more experimental) version of Jupyter. More details and information are found here: https://jupyter-notebook-beginner-guide.readthedocs.io/en/latest/index.html

In [12]:
YouTubeVideo(PL[5])
Out[12]: