Starting a new IPython or Jupyter session

Before we can get our hands on NumPy, we need to open an IPython shell or start a Jupyter Notebook:

  1. Open a terminal like we did in the previous chapter, and navigate to the opencv-machine-learning directory:
      $ cd Desktop/opencv-machine-learning
  1. Activate the conda environment we created in the previous chapter:
      $ source activate Python3  # Mac OS X / Linux
$ activate Python3 # Windows
  1. Start a new IPython or Jupyter session:
      $ ipython           # for an IPython session
$ jupyter notebook # for a Jupyter session

If you chose to start an IPython session, the program should have greeted you with a welcome message such as the following:

$ ipython
Python 3.5.2 |Continuum Analytics, Inc.| (default, Jul 5 2016, 11:41:13) [MSC v.1900 64 bit (AMD64)]

Type "copyright", "credits" or "license" for more information.

IPython 3.5.0 -- An enhanced Interactive Python.
? -> Introduction and overview of IPython's features.
%quickref -> Quick reference.
help -> Python's own help system.
object? -> Details about 'object', use 'object??' for extra details.

In [1]:

The line starting with In [1] is where you type in your regular Python commands. In addition, you can also use the Tab key while typing the names of variables and functions in order to have IPython automatically complete them.

A limited number of system shell commands work, too--such as ls and pwd. You can run any shell command by prefixing it with a !, such as !ping www.github.com. For more information, check out the official IPython reference at https://ipython.org/ipython-doc/3/interactive/tutorial.html.

If you chose to start a Jupyter session, a new window should have opened in your web browser that is pointing to http://localhost:8888. You want to create a new notebook by clicking on New in the top-right corner and selecting Notebooks (Python3):

Creating a new Jupyter Notebook

This will open a new window that looks like this:

A new Jupyter Notebook

The cell labeled with In [ ] is the same as the command line in an IPython session. Now you can start typing your Python code!