We will not cover installation during the meetup.
Anaconda is the name of a distribution of Python created by a company with the same name (formerly Continuum Analytics). It is currently the most popular distribution of Python for data science and contains all the popular libraries plus some extra software.
- Please download Anaconda with Python 3 now. Select all the default installation instructions.
Jan 1, 2020 will mark the last day that Python 2 will be officially supported. Python 3 is the present and future and nearly all serious development will use it.
Let's ensure that you the Anaconda distribution got installed correctly and that you are indeed running the latest version of Python 3.
Open up the program Anaconda Prompt
. This program will look very similar to the normal Command Prompt
but will place the destination of the latest Python 3 version at the beginning of the path.
Open up a terminal
- Type
python
at the prompt - Ensure that in the header you see Python version 3.X where X >= 6
- If you don't see this header with the three arrow
>>>
prompts and instead see an error, then we need to troubleshoot here. - If you are running Python version 2.X, see these instructions below
- Press
ctrl + d
to exit Python.
The error message that you will see is 'python' is not recognized as an internal or external command...
Make sure you are running the Anaconda Prompt
and not the normal Command Prompt
.
If you are in Anaconda Prompt
and still getting this message then see the optional installation below.
The error message you should have received is python: command not found
. Let's try and find out where Python is installed on your machine.
- Run the command:
$ which -a python
- This outputs a list of all the locations where there is an executable file with the name
python
- This location must be contained in something called the path. The path is a list (separated by colons) containing directories to look through to find executable files
- Let's output the path with the command:
echo $PATH
- My path contains the directory (
/Users/Ted/Anaconda/bin
) from above so running the commandpython
works for me. - If your path does not have the directory outputted from step 1 then we will need to edit a file called
.bash_profile
(or.profile
on some linux machines) - Make sure you are in your home directory and run the command:
nano .bash_profile
- This will open up the file
.bash_profile
, which may be empty - Add the following line inside of it:
export PATH="/Users/Ted/anaconda3/bin:$PATH"
(use your Anaconda directory) - Exit (
ctrl + x
) and make sure to save - Close and reopen the terminal and execute:
echo $PATH
- The path should be updated with the Anaconda directory prepended to the front
- Again, type in
python
and you should be good to go .bash_profile
is itself a file of commands that get executed each time you open a new terminal.
It is possible to run Python from the Command Prompt
directly in Windows. If you so desire, manually configure your Command Prompt.
If you have a previously installed Anaconda distribution with Python 2, then you might want to consider removing it from your system. Only take this option if you are removing the Anaconda distribution itself that contains Python 2. Many machines will have Python 2 built-in. Unless you have some legacy project that must be maintained in Python 2, there is no use in keeping it.
The path is a list of directories that the computer will search in order, from left to right, to find an executable program with the name you entered on the command line. It is possible to have many executables with the same name but in different folders. The first one found will be the one executed.
- Windows:
path
orset %PATH%
- Mac/Linux
echo $PATH
- Windows:
where program_name
- Mac\Linux:
which program_name
- Windows: Use the set (or setx) command or from a GUI
- Mac\Linux: By editing the
.bash_profile
as seen in the troubleshooting section above.
IPython stands for interactive Python and is an enhanced Python environment on the command line. It is superior to the default interactive environment that we first ran above.
Open up a terminal/Anaconda Prompt and execute ipython
. Again, you should see a header that states the exact same information as before. Press ctrl + d
to exit.
The Jupyter Notebook is one of the most popular environments for running Python code for data scientists. It allows you to embed text, images, and code altogether in a single document. Let's start a Jupyter Notebook now.
- Open a terminal/Anaconda Prompt execute
jupyter notebook
- Your browser should open with a new tab that shows the contents of the current directory - the location where you ran the command.
- If you did not change directories after opening your terminal/Anaconda Prompt then you should see the contents of your home directory. Mine looks like this:
- Click on the New button on the top right of the page and you will have started a Jupyter Notebook which you can then run Python commands.
- To exit the Jupyter Notebook, you will need to go back to the terminal/Anaconda Prompt where you launched it and press
ctrl + c
twice.
When you install the Anaconda distribution, you will also install a software program named Anaconda Navigator. This is a graphical user interface (point and click program) that also allows you to start running a Python environment without the being on the command line.
- Find and open the Anaconda Navigator program to get a screen that looks like this:
- Under the Jupyter Notebook section, click Launch
- A new terminal/Anaconda Prompt will automatically pop-up and a new browser tab will open up as well showing the contents of the home directory.
- This is the exact same environment that we launched with the command line above.
- To exit, you must again go to the terminal/Anaconda Prompt and press
ctrl + c
twice.
python
and ipython
are both executable programs that run Python interactively from the command line. The python
command runs the default interpreter, which comes prepackaged with Python. There is almost no reason to ever run this program. It has been surpassed by ipython
(interactive Python) which you also run from the command line. IPython adds lots of functionality such as syntax highlighting and special commands.
The Jupyter Notebook is a browser based version of IPython. Instead of being stuck within the confines of the command line, you are given a powerful web application that allows you to intertwine code, text, and images. See this for more details of the internals.
Jupyter Lab is yet another interactive browser-based program that allows you to have windows for notebooks, terminals, data previews, and text editors all on one screen. It is the "next-generation user interface for Project Jupyter".
As you can see at the top of this page, there are multiple files in this repository.
- The README file that you are reading right now
- The
.ipynb
files where all the magic happens - A resources section with lots of places to get help and learn more