Software installation

3.2. Software installation#

Hands-on experience with Python coding is an essential part of mastering the skill of programming. To do this on your laptop, you will need to install the necessary software.

This page guides you through the installation steps for:

  • Miniconda

  • Visual Studio Code (VS Code)

  • Git

The first two are essential for being able to start programming in Python on your computer. The third component is needed for managing your code and tracking the changes you make in it.

When installing individual components, you always have to make sure to follow the appropriate instructions depending on the operating system of your laptop (Windows, macOS, or Linux). Follow the installation order as presented in this book (i.e., install Miniconda first, etc.).

3.2.1. Miniconda#

Miniconda is a minimal installer for conda and a small version of Anaconda. It is a distribution of Python programming language, which comes with some pre-installed packages, such as pip.

Before you start using Python, you need to install Miniconda. Later, we will need a few packages that are not included in Miniconda; we will install them at that point.

  1. Go to Miniconda installer page.

  2. Pick the latest Miniconda installer suitable with your system Windows 64-bit.

  3. Run .exe file and start installation.

  4. Follow the recommended settings.

  5. Check if you have miniconda3 folder in the path: C:\Users\yourUserName.

  6. Open Anaconda Prompt which was installed with Miniconda.

  7. Type conda to see the possible commands.

  8. Try the conda list command to see if the installation is successful.

../../_images/miniconda1.png

Note that so far you’ve used three different terminals:

  • Command Prompt (for Windows native commands - you used it to find out the version of your Windows system prior to installing Cygwin)

  • Cygwin Terminal (to interpret Linux commands)

  • Anaconda Prompt (the prompt which has access to conda commands)

Advanced information (optional):

  • You can also link conda commands to Windows’ native Command Prompt. This is optional and not needed in this book. To be able to use conda commands in Command Prompt, you would need to add the Miniconda installation to your system’s PATH environment variable. You can use the conda init command to set things up automatically. To do so, open Anaconda Prompt and run the following command: conda init cmd.exe. Then restart your Command Prompt.

  1. Click on the Apple symbol in the top left corner of your screen and then click About This Mac. Take note of the type of processor/chip you have (Intel vs. M1/M2/M3); this will inform your choices in this installation.

  2. At this website, click on the Tab “macOS graphical installer”.

  3. Click on the link “Download the .pkg installer” in the first installation step and select the corresponding file from the table:

  • “Miniconda3 macOS Intel x86 64-bit pkg” if your laptop has an Intel chip.

  • “Miniconda3 macOS Apple M1 64-bit pkg” file if your laptop has an M1, M2, or M3 chip. This will download a .pkg file into your Downloads folder.

  1. Return to the previous webpage with installation instructions and follow steps 3 and 4: navigate to the downloaded .pkg, double-click on it, and follow the instructions. Accept the default settings. When installation is finished, you can move the installer to the Bin.

  2. Let’s verify whether the installation was successful by following steps 5 and 6. First, use cmd + space bar to open the Spotlight search on your Mac. Type in “terminal” to open the terminal application. This will look like this:

../../_images/Miniconda_Mac_1.png
  1. Type in conda list and press Enter. If your Miniconda installation was successful, you will get output like this (you can also scroll up to see the entire list of installed packages):

../../_images/Miniconda_Mac_2.png
  1. Before starting the installation, it’s helpful to know your system’s architecture (e.g., x86_64 or ARM). This will help ensure you download the correct version of Miniconda. You can find this information using the following command in your terminal:

uname -m

If the output is x86_64, your system has a standard Intel/AMD 64-bit processor. If the output is aarch64, your system has an ARM processor.

  1. At the Miniconda website, click on the Linux tab to view the download options. Choose the appropriate installer based on your processor type determined in step 1. For Intel/AMD 64-bit systems, download the Miniconda3 Linux 64-bit installer. For ARM-based systems, download the Miniconda3 Linux ARM64 installer.

  2. Once the installer is downloaded, navigate to the folder where it is saved (typically your Downloads/ folder). You can do this using the cd command in your terminal. Make the installer executable with the chmod command and then run it, e.g.:

chmod +x Miniconda3-latest-Linux-x86_64.sh
./Miniconda3-latest-Linux-x86_64.sh

During the installation follow the prompts and review the license agreement. Accept the default installation location. At the end, it will ask if you want to initialize Miniconda (conda init). Confirm by typing yes.

  1. To check if the installation was successful, close your current terminal and open a new one. Then, type conda list. If your Miniconda installation was successful, you will see a list of installed packages (check the macOS tab in these instructions to see an example).

  2. During installation, if you accepted the conda init prompt (which modifies the shell’s startup files), conda commands should already be available in any terminal session. You can check this by opening a new terminal and running conda list. Otherwise, if you chose not to let the installer modify your PATH, it is useful to add Miniconda to your PATH manually. To do so, add the following line to the end of your .bashrc or .zshrc file (depending on your shell) and then run with source:

export PATH="$HOME/miniconda3/bin:$PATH"
source ~/.bashrc  # or source ~/.zshrc

3.2.2. Visual Studio Code#

To write Python code, you will use an integrated development environment (IDE) called Visual Studio Code (VS Code), which you can use to write, test, and debug your code. VS Code generally works well on various operating systems (Windows, macOS, Linux) and supports multiple programming languages besides Python, which may come in handy in the future should you decide to use another language. Of course, there is a choice of available IDEs, so in the future you may also choose to use a different one (PyCharm and Spyder are popular choices).

  1. Go to Download Visual Studio Code.

  2. Download the .exe file for Windows.

  3. Follow the default settings.

  4. This will directly launch a VS Code window. If you notice a “release note” opened as a tab in VS code, you can close the tab.

You now have VS Code installed. We still go trough its setup and basic usage on the next page.

  1. Navigate to this website and click on the Download icon for Mac. The download will happen either immediately, or you may need to press “Allow” when asked whether you want to allow the download.

../../_images/VSCode_Mac_1.png
  1. Navigate to the downloaded file. The downloaded file will be either:

  • A zip file: double-click on it to unzip it, and then open the unzipped VS Code application, or

  • VS Code application: double-click on it to open it. If you’re asked whether you’re sure if you want to open this app, press “Open”. VS Code should then open and you should see the screen such as this:

../../_images/VSCode_Mac_2.png

You now have VS Code installed. We will go trough its setup and basic usage on the next page.

  1. Go to Download Visual Studio Code. Installation guide can be found here. Otherwise, you can follow the instructions below.

  2. Select the tar.gz based on your Linux system.

  3. Use your terminal to extract the tarball (tar.gz): tar -xvf code-*.tar.gz. Navigate into the extracted folder (e.g., cd VSCode-linux-x64) and run the application using ./code.

  4. In general, once the installation is complete, you can launch Visual Studio Code by:

  • Searching for “Visual Studio Code” in your application menu, or

  • Typing code in the terminal. This should directly launch a VS Code window.

Optional: alternative steps 2 and 3.

Option 1. If you download .deb in step 2 (for Debian/Ubuntu), to install VS Code you need to open a terminal and use the cd command to navigate to the directory where the downloaded file is located (typically ~/Downloads/). Then install the package using sudo dpkg -i code_*.deb. If there are dependency issues, run sudo apt-get install -f .

Option 2. If you download .rpm in step 2 (for Fedora), to install VS Code you need to open the terminal and use the cd command to navigate to the directory where the downloaded file is located (typically ~/Downloads/). Then install the package using sudo dnf install code-*.rpm

3.2.3. Git#

Git is a tool used for code management. It’s a free and open-source version control system (see version control in Computer glossary). Git is incredibily useful (and therefore very widely used) for tracking changes in your code, for sharing code, and for collaborating on code with others. Any programming endeavours you may encounter at your future work will almost certainly include working with Git.

  1. Go to Git - Downloading Package.

  2. From the standalone installers, pick the Windows version your computer has and download.

  3. Run the .exe file and stay with the default settings until you need to choose the default editor. Select “use VS code as Git’s default editor” from the drop-down menu.

Open the Terminal application, type in git --version and press Enter. Depending on the outcome of this action, you should follow scenario 1, 2, or 3.

Scenario 1

Running git --version in terminal displayed Git version, which looks like this:

../../_images/git1.png

Note that the exact version displayed may be different than 2.39.5 and that is alright. If a version was displayed, you’re all set.

Scenario 2

Running git --version in terminal gave a longer message which mentions XCode, and a new window popped up prompting you to install it. In this case, agree to install and follow the installation instructions. Once it’s done, go back to terminal and try running git --version again. This time, you should get the outcome shown in Scenario 1, and then you’re all set.

Scenario 3

If even after installing XCode (Scenario 2) the terminal doesn’t display Git version, i.e., if there is no Git on your computer, you can choose to either follow these instructions or follow steps 1-4:

  1. Open the terminal.

  2. Install Homebrew by running: /bin/bash -c "$(curl -fsSL https://raw.githubusercontent.com/Homebrew/install/HEAD/install.sh)"

  3. Install Git with Homebrew: brew install git

  4. Check Git installation by running git --version.

  1. For Debian/Ubuntu: Open a terminal. Run the following commands:

sudo apt-get install git
  1. For Fedora: Open a terminal. Run the following command:

sudo dnf install git
  1. After installation, verify that Git is installed by running git --version. This command will display the installed Git version.