Appendix A: Installing 3rd-Party Modules
In addition to built-in modules you get with Python by default, there are many modules written by others that you can make use of. You can install third-party modules using Python’s pip
tool. This tool downloads and installs Python modules onto your computer from https://pypi.python.org/ (aka PyPi or Python Package Index).
First, ensure that you have pip
installed by running this command in a command shell (not Python interpreter shell), which should print out the version of the pip tool you have.
pip --version
After that, to install a third-party module (or packages as they are sometimes called), you can run the pip install {packagename}
command.
The example below shows how to install the colorama
module that allows you to colorize text printed out to the console.
pip install colorama
Collecting colorama
Downloading colorama-0.3.9-py2.py3-none-any.whl
Installing collected packages: colorama
Successfully installed colorama-0.3.9
After installing colorama, you can import it into your code and use its features to print colorized text.
import colorama
colorama.init() # one-time initialization
print(colorama.Fore.YELLOW + ' Some yellow text')
print(colorama.Fore.BLUE + colorama.Back.WHITE + ' Some blue text in a white background')
print(colorama.Style.RESET_ALL + ' Back to normal now')
Some useful third-party modules:
colorama
: For colorizing text printed in the consoleselenium
: For automating the Browserpyzmail
: For sending emailstwilio
: For sending SMSPyPDF2
: For working with PDF filespyperclip
: To access the clipboard of the operating systemdateparser
: To parse natural language repsentation of dates e.g.,in 2 days
,tomorrow
Resources: