Skip to content

Latest commit

 

History

History
259 lines (217 loc) · 11.8 KB

File metadata and controls

259 lines (217 loc) · 11.8 KB

Prerequisities

To ensure that the scripts/applications that you will write in this course works seamlessly, we need to install few applications/libraries. I have detailed ways to do the same for different OS distributions here. The recommended way for your OS is also marked.

Dependencies which we will install

  • A shell runnning sh compliant implementation (bash/zsh/fish)
  • Python 3.x (preferably the latest)
  • Jupyter for installing notebooks. IMPORTANT: The instructions for installing Jupyter are attached at the end of this guide and is OS-agnostic.

OS-agnostic method #0 (Easiest, definitely works)

You can use cloud based services to create/modify/access your own Jupyter notebooks. The most popular one is Google Colaboratory, for which you need to sign into Google.

OS-agnostic method #1 (Easiest and definitely works)

Install your favorite Python IDE (Integrated Development Environment) such as PyCharm or Spyder, to name a few. The list is non-exhaustive and an internet search should reveal more.

OS-agnostic method #2 (Easiest and definitely works)

We can load a virtual machine in your environment—it’s essentially an ‘OS’ that runs inside your ‘OS’.

Follow the steps listed here 7. Download both:

VirtualBox

ComputeImage

You should have a working debian installation with your favorite

shell and python3 already installed

Ubuntu/Debian (and equivalent distros)

Try any one of the following methods.

Method #1 (Recommended, Easiest)

  • Almost works off the shelf! You have access to the shell from the Terminal application.
  • Python3 can be installed directly using the Conda distribution 4. Installation of the Anaconda distribution for Linux systems can be found here.
  • Enjoy using Python from the Conda distribution on the Terminal.
  • To install packages in the current virtual environment (details skipped for brevity) do
    	  conda update conda
    	  conda install -c anaconda numpy scipy matplotlib pandas
        

Method #2 (Somewhat harder, not recommended)

  • Almost works off the shelf! You have access to the shell from the Terminal application.
  • Install the Spyder IDE from the Terminal using the following steps. Also gives access to an editing environment which provides useful syntax-highlighting, among other shiny features.
    	# Fetches up-to-date package information from
       #the Ubuntu aptitude repository
    	sudo apt-get update
    
    	# Upgrades all packages
    	sudo apt-get upgrade
    
    	# Install Python3, if not already there
    	sudo apt-get install spyder3
        
  • You can now use the Spyder IDE to launch Python processes.

Method #3 (Recommended if you want more control)

  • Almost works off the shelf!
  • To ensure that all packages are up to date, and that you have the latest Python installation run the following commands in your Terminal (type terminal in the Ubuntu dash, and enter the following commands)
# Fetches up-to-date package information from the Ubuntu aptitude repository
sudo apt-get update

# Upgrades all packages
sudo apt-get upgrade

# Install Python3, if not already there
sudo apt-get install python3-pip

# See if pip3 installed successfully and is in your path
which pip3

# Install other libraries using pip
pip3 install numpy scipy matplotlib pandas
  • You can now type in python3 in the Terminal app prompt and will be taken to the python environment.

Method #4 (Not tested and not recommended)

Method #5 (Good practice for independent external installation of software in Ubuntu)

  • Use an external package manager, the recommended choice being Linuxbrew. It is painful to install, especially if you can’t navigate your way around the terminal. If you are just getting used to the terminal environment, this option is not for you.
  • Follow the instructions for building Linuxbrew from their website first.
  • After successfully installing Linuxbrew, just type installation
		brew install python3
  • This should also install pip3, which you can use to install Python packages.

Windows 10

  • Unfortunately Windows environment uses a different shell interpreter, which complicates scripting and development. However you can run a Linux subsystem perfectly within Windows!
    • This needs Windows build 16215 or later for painless processing (which you most probably have as Microsoft aggressively updates their products).
    • If you want you can check your build here. 1

Enabling access to sh compliant shell 23

  • Open PowerShell as Administrator and run:
Enable-WindowsOptionalFeature -Online -FeatureName Microsoft-Windows-Subsystem-Linux
  • Restart your computer when prompted.
  • Once this is done, you can install the Linux distro of your choice from the Windows Store.
    • Open the Microsoft Store and choose your favorite Linux distribution (say Ubuntu)
    • From the distro’s page, select “Get”
  • Launch the distro from the start menu, like any other app. You can find it at <distro_name> (in the case of Ubuntu, this will be called Ubuntu)
    • The first launch will take some time
  • Set the required Linux username and password (this can be different than you Windows user name and password)
  • You are now running a sh compliant shell. Type in the following to update the repository information.
    # Fetches up-to-date package information
    #from the Ubuntu aptitude repository
    sudo apt-get update
    
    # Upgrades all packages
    sudo apt-get upgrade
        

Installing Python

MacOS

Try any one of the following methods.

Method #1 (Recommended, Easiest)

Method #2

Method #3 (Use a package manager)

  • MacOS sorely misses a package manager for installation of binaries. So you can install the Homebrew package manager found here.
  • The installation might seem long drawn (I have listed the time needed below), but will usually proceed without difficulty. You can consult the reference 6 if you face any issues. The steps are given below:
  • You need to install Command Line Tools of Xcode. Type in the following in the terminal to see if you have already installed it
xcode-select -p

If the output is non-null, you can safely skip to the next step. If not, type in the following in your terminal:

xcode-select --install

This usually pops up a display window like this. The instructions in the alert box are confusing. You don’t need to “Get Xcode” from the App Store. Just click “Install” for the Xcode Command Line Tools. If you have a slow Internet connection, this step may take many minutes. After the installation repeat the xcode-select -p command and this time you will see the path of installation of Command Line Tools in your terminal prompt.

  • Now we can install Homebrew by typing in the following commands
ruby -e "$(curl -fsSL https://raw.githubusercontent.com/Homebrew/install/master/install)"

Quoting Hitchhiker’s guide to Python,

“The script will explain what changes it will make and prompt you before the installation begins.”

  • You should then be able to type in
		  brew install python3

and Python3, along with pip should be installed.

Jupyter notebooks

  • Note: Python3 is a prerequisite to install Jupyter. You can find all the relevant information in Jupyter’s home page 8.
  • If you have your Python installation done via Conda, you should also have jupyter-notebook installed. To verify this type
    	jupyter notebook
        

    in your terminal to see the Jupyter console up and running in your browser.

  • Alternatively, you can also install Jupyter quickly via pip. Just type
    	#Upgrades pip repository information
    	pip3 install --upgrade pip
    	pip3 install jupyter
        

    in your terminal prompt. You can verify successful installation by typing in your terminal:

    	jupyter notebook
        

Footnotes

8 https://jupyter.org/install

7 https://andreask.cs.illinois.edu/ComputeVirtualMachineImages

6 The Hitchhiker’s guide to Python

5 Python

4 Conda Install for Linux

3 Initialize your distro

2 Install Linux on Windows

1 Check your Windows build here