Chapter 2. Python Infrastructure

In building a house, there is the problem of the selection of wood.

It is essential that the carpenter’s aim be to carry equipment that will cut well and, when he has time, to sharpen that equipment.

Miyamoto Musashi (The Book of Five Rings)

For someone new to Python, Python deployment might seem all but straightforward. The same holds true for the wealth of libraries and packages that can be installed optionally. First of all, there is not only one Python. Python comes in many different flavors, like CPython, Jython, IronPython, and PyPy. Then there is the divide between Python 2.7 and the 3.x world.1

Even after you’ve decided on a version, deployment is difficult for a number of additional reasons:

  • The interpreter (a standard CPython installation) only comes with the so-called standard library (e.g., covering typical mathematical functions)

  • Optional Python packages need to be installed separately—and there are hundreds of them

  • Compiling/building such nonstandard packages on your own can be tricky due to dependencies and operating system–specific requirements

  • Taking care of these dependencies and of version consistency over time (i.e., maintenance) is often tedious and time consuming

  • Updates and upgrades for certain packages might necessitate recompiling a multitude of other packages

  • Changing or replacing one package might cause trouble in (many) other places

Fortunately, there are tools and strategies available that can help. ...

Get Python for Finance, 2nd Edition now with the O’Reilly learning platform.

O’Reilly members experience books, live events, courses curated by job role, and more from O’Reilly and nearly 200 top publishers.