官术网_书友最值得收藏!

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!

主站蜘蛛池模板: 济源市| 汶上县| 陇西县| 澳门| 博罗县| 阜南县| 兖州市| 泰来县| 丁青县| 保靖县| 缙云县| 岫岩| 囊谦县| 罗田县| 莒南县| 东乡县| 南召县| 龙里县| 通州区| 泗阳县| 舒城县| 定州市| 肥东县| 古丈县| 特克斯县| 饶阳县| 遵义县| 广昌县| 博客| 新晃| 长沙市| 枝江市| 休宁县| 巩义市| 仪征市| 巴林左旗| 定州市| 襄垣县| 枣庄市| 舟山市| 疏勒县|