Appendix A. Python at a Glance

According to the Association for Computing Machinery, Python is the top teaching language in the United States, with it being more commonly taught in introductory programming classes than BASIC, Java, and even C. This section will cover the basics of installing, using, and running Python 3.x and Python programs. 

Installation and “Hello, World!”

If you have OS X or almost any flavor of Linux, you likely already have Python installed. If in doubt, type the following into your command line:

$python --version

We will be using Python 3.x throughout this book. If you see that you have Python 2.x installed, you upgrade on Linux simply by calling apt-get:

$sudo apt-get install python3

Note this might involve needing to execute your Python code by typing $python3 myScript.py into the command line, rather than $python myScript.py.

The OS X operating system, as of this writing, has Python 2.7 installed by default. To install Python 3.x, download an installer from the Python website. Again, if you are running both Python 2.x and Python 3.x simultaneously, you might need to explicitly call Python 3.x using $python3. 

For Windows users without Python installed, there are precompiled installers available for download. Simply download, open, and install. You might also need to set the Windows system path to the directory in which you install Python in order to tell the operating system where it’s at, but the website and installers have fairly straightforward ...

Get Web Scraping with Python 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.