Setup

To run the code examples in this book, you will need Python 3.6 (or newer), Jupyter, and a bunch of libraries from the Python data stack.

  • PDF / 632,722 Bytes
  • 8 Pages / 439.37 x 666.142 pts Page_size
  • 40 Downloads / 200 Views

DOWNLOAD

REPORT


Setup To run the code examples in this book, you will need Python 3.6 (or newer), Jupyter, and a bunch of libraries from the Python data stack.

Anaconda The easiest way to get everything that you’ll need for this book is to install Anaconda.1 Just go to the Anaconda website and download the relevant distribution for your operating system.

https://www.anaconda.com/

1

© Max Humber 2018 M. Humber, Personal Finance with Python, https://doi.org/10.1007/978-1-4842-3802-8_1

1

Chapter 1

Setup

Anaconda works on Windows, macOS, and Linux. I run macOS, so I’m going to demo that install process. For those who are not on macOS, Anaconda has some excellent install documentation available online.2 Once you’ve downloaded the distribution, open the installer and click through all the prompts.

https://docs.anaconda.com/anaconda/install/

2

2

Chapter 1

Setup

Anaconda will install an up-to-date Python 3.6 and above release, as well as a bunch of useful Python packages such as pandas, numpy,3 and beautifulsoup.4

w ww.numpy.org/ https://www.crummy.com/software/BeautifulSoup/

3 4

3

Chapter 1

Setup

After installation, open Terminal—or your preferred command-line interface—and run all the bits after the $ to make sure that Anaconda did its thing.

If your Python is in Users//anaconda3/bin/python and typing in python spits out something like Python 3.6.4 |Anaconda, then you’re almost ready to rock and roll. Just one more thing…

4

Chapter 1

Setup

nteract Note  If you already know how to use Jupyter Notebooks, this step isn’t strictly necessary. However, nteract is pretty darn slick; you should give it a fair shake! To actually run Python code, you’ll need a Jupyter5 Notebook interface called nteract. While Jupyter is an open-source web application that allows you to create documents that contain live code (and was installed for you with Anaconda), nteract is a super user-friendly desktop-based skin for Jupyter. You can download nteract from the nteract.io website.6

h ttps://jupyter.org/ https://nteract.io/

5 6

5

Chapter 1

Setup

Once it’s downloaded and installed, you can load a fresh Jupyter Notebook by clicking the nteract icon. You will be greeted with a screen that looks like this:

With a blank slate, you can now run arbitrary Python code inside empty cells, the results of which will be printed just below the input cell.

6

Chapter 1

Setup

To execute code inside a cell, just hit Shift+Enter. To insert a new cell, just select Edit ➤ New Code Cell or use the shortcut Cmd+Shift+N. You can find a list of all the macOS (and Windows) shortcuts in the nteract USER_GUIDE.md.7 Quickly make sure that imports are working for you by running the following: import pandas as pd If everything is in working order, nothing should’ve happened! However, if after executing import pandas as pd you get something like this:

https://github.com/nteract/nteract/blob/master/USER_GUIDE.md

7

7

Chapter 1

Setup

--------------------------------------------------------------ModuleNotFoundError           Traceback (mos