- Machine Learning for OpenCV
- Michael Beyeler
- 344字
- 2025-04-04 18:50:48
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:
- Open a terminal like we did in the previous chapter, and navigate to the opencv-machine-learning directory:
$ cd Desktop/opencv-machine-learning
- Activate the conda environment we created in the previous chapter:
$ source activate Python3 # Mac OS X / Linux
$ activate Python3 # Windows
- 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.
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):

This will open a new window that looks like this:

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