This is guide for those trying to install Python for the first time, or who already have Python installed and want to install a set of packages/libraries
The options are:
- Installing through Anaconda - for those people who aren't concerned about space/memory requirements on their computers. Installs base Python along with a number of useful packages.
- Miniconda - installs base Python, and allows the user to control which packages to install. Good for people with limited space.
- Package specific - for those who already have Python installed via pip
Anaconda is a Python distribution platform which allows you to install and manage up to 720 different Python packages through the Anaconda installer, conda
. If you have at least 400MB of free space on your laptop, then I would recommend using this, as it will automatically install many of the packages that you will find useful for your research and future coding.
Just navigate to the Anaconda home page and follow the instructions to download Python version 3.6 for your Windows, Mac or Linux device.
For windows devices - if you are not sure and are using windows 7, 8, 9 or 10, then download the 64-bit exe installer.
Please ensure that you allow Anaconda to register it's version as Python as the default on your device. This means that, if you already have Python installed (as MacOS does natively), you are allowing Anaconda to use it's own version of Python - and the associated packages - when you are coding. If you change this option you will run into errors when trying to use your packages, and in particular, when trying to run the jupyter notebook required for this workshop.
This is the better option for people with limited memory left on their device. This option will install base Python onto your device, and allows you to install specific packages according to your requirements.
-
Download the
python 3 exe installer
from https://conda.io/miniconda.html (If you are not sure and you are using windows 7, 8, 9 or 10, then download the 64-bit exe installer) -
Run the exe installer and install using default choices. By clicking next. (The installation might take a few minutes if the computer is slow, you can click "Show Details" to see the installation progress.
-
When installation is complete, find and open a program called
Select Anaconda Prompt
from the Windows Start Menu.
This will open a new window with a black background (it might keep blinking if the computer is slow). Wait until you can start typing
-
Type
conda install jupyter matplotlib numpy pandas
and hitENTER
key. When asked do you want to proceed, typey
and hitENTER
.This will take a few minutes to download the packages.
If you wish to install more packages in the future, you just need to use the
conda install <package name>
from your command line. -
To view a list of packages and versions installed, or to confirm that a package has been added or removed, type
conda list
. Confirm that jupyter, numpy and matplotlib packages have been installed -
The workshop will be using jupyter notebooks. To see how you can launch this, go to the Launching Jupyter Notebook section below.
-
If you need to uninstall miniconda for any reason, you can do this through "Add or remove Program" in the control panel, by removing "Python 3.6(Miniconda)"
- In your browser download the Python 3.6 Miniconda installer for OS X from https://conda.io/miniconda.html, then in your terminal window type the following:
bash Miniconda3-latest-MacOSX-x86_64.sh
-
Follow the prompts on the installer screens. If unsure about any setting, simply accept the defaults as they all can be changed later. After installation is complete, close your terminal window.
-
Re-open your terminal window, and type
conda --version
into the command terminal to test that miniconda has been installed. Conda should respond with the version number that you have installed, like: conda 3.11.0
NOTE: If you see an error message, check to see that you are logged into the same user account that you used to install Anaconda or Miniconda, and that you have closed and re-opened the terminal window after installing it.
-
Type
conda install jupyter numpy matplotlib pandas
and hitENTER
key. When asked do you want to proceed, typey
and hitENTER
. If you wish to install more packages in the future, you just need to use thisconda install <package name>
from your command line. -
To view a list of packages and versions installed, or to confirm that a package has been added or removed, type
conda list
. Confirm that jupyter, numpy and matplotlib have been installed -
The workshop will be using jupyter notebooks. To see how you can launch this, go to the Launching Jupyter Notebook section below.
-
If you need to uninstall miniconda for any reason, open a terminal window and remove the entire miniconda install directory by typing:
rm -rf ~/miniconda
You may also edit ~/.bash_profile and remove the miniconda directory from your PATH environment variable, and remove the hidden .condarc file and .conda and .continuum directories which may have been created in the home directory with: rm -rf ~/.condarc ~/.conda ~/.continuum
- In your browser download the Python 3.6 Miniconda installer for OS X from https://conda.io/miniconda.html, then in your terminal window type the following:
bash Miniconda3-latest-Linux-x86_64.sh
-
Follow the prompts on the installer screens. If unsure about any setting, simply accept the defaults as they all can be changed later. After installation is complete, close your terminal window.
-
Close and re-open your terminal window. Type
conda --version
into the command terminal to test that miniconda has been installed. Conda should respond with the version number that you have installed, like: conda 3.11.0 -
Type
conda install jupyter numpy matplotlib pandas
and hitENTER
key. When asked do you want to proceed, typey
and hitENTER
. If you wish to install more packages in the future, you just need to use thisconda install <package name>
from your command line. -
To view a list of packages and versions installed, or to confirm that a package has been added or removed, type
conda list
. Confirm that jupyter, numpy and matplotlib have been installed -
The workshop will be using jupyter notebooks. To see how you can launch this, go to the Launching Jupyter Notebook section below.
-
If you need to uninstall miniconda for any reason, open a terminal window and remove the entire miniconda install directory:
rm -rf ~/miniconda
.
You may also edit ~/.bash_profile
and remove the miniconda directory from your PATH environment variable, and remove the hidden .condarc file and .conda and .continuum directories which may have been created in the home directory with rm -rf ~/.condarc ~/.conda ~/.continuum
.
As an existing Python user, you may wish to install Jupyter using Python’s package manager, pip, instead of Anaconda.
Jupyter installation requires Python 3.3 or greater, or Python 2.7. Please ensure you have these installed first before proceeding.
-
Ensure that you have the latest pip; older versions may have trouble with some dependencies:
pip3 install --upgrade pip
(Usepip
instead ofpip3
if using legacy Python 2.) -
Install the Jupyter Notebook using:
pip3 install jupyter
(Usepip
instead ofpip3
if using legacy Python 2). Close and re-open your terminal window. Similarly, if you wish to install other packages in the future, you can use `pip3 install
For many of these sessions, we're going to be working in the Jupyter notebook. Jupyter is launched from your command prompt (windows) or command terminal (MacOS/Linux), which you can find by searching your applications.
After opening the command terminal, you should see a black screen and a >
prompt after a file path, usually within your C:\
drive.
When Jupyter launches, it sets its "home" folder to be the folder you are in when you launch the notebook, and it can access any sub-folders and files within that location.
This means it's in our best interest to launch from an area where we'll be able to access all of the files we'll require. This is usually in your user folder.
Therefore, in your terminal, type cd C:/Users/<YourUserName>
. Once there, type in the command jupyter notebook
to launch Jupyter.
You should then see the terminal generate a bunch of text, and it should then open the jupyter home page within a browser window. This should be within whichever browser application is currently set as your default. You can change this in your settings.
(MacOS/Linux) If the terminal does not automatically open within your browser, you can copy the http://localhost:888...etc
link into a new browser tab.
This should open to the Jupyter home folder, which will look something like this
You can click on the blue links inside the main console to navigate through your folders and files. To the top-right of your files box are some command buttons. These allow you to do things like create new folders, new text (*.txt) files, or a new iPython notebook. We will be writing and running our code from inside these *.ipynb files.
When you create a new *.ipynb notebook, you'll get something that looks like this, except empty:
Play around with the notebook, and have a look to see what you can do. If you'd like a more guided tour/playbox, you can find one here