Installing and setting up libraries
Before we get into the basic concepts of searching, we will take a look at the following libraries that have to be installed and how to install them in Windows:
- Python: You can download and install Python libraries from https://www.python.org/downloads/, depending on your operating system
- Graphviz: This open source graph visualization software can be downloaded from http://graphviz.org/download/
- Pip: The tools for installing Python packages are as follows:
- Pydot: A Python interface to Graphviz's DOT language
- Matplotlib: This is a Python 2D plotting library
Execute the steps in the following section to install the preceding libraries.
Setting up Python
The steps for setting up Python are as follows:
- For the applications in this book, we'll be using Python 2.7.6, which we can download from https://www.python.org/downloads/.
- Once an appropriate installer has been downloaded, double-click on it and go ahead with the default options.
- Based on your operating system, select the Python installer to download, as shown in the following screenshot:

Figure 1
- The following screenshot shows the location where Python will be installed; make a note of this location:

Figure 2
Now, Python will be installed.
- The next step is to add Python's path to the
Path
environment variable. In theSystem Properties
|Advanced
tab, click on theEnvironment Variables...
button. - In the
Environment Variables…
window, go toSystem variables
|Path
and add the Python location that you made a note of in step 4 (which isC:\Python27
in our case).
- Now, to check whether Python works, open the Command Prompt and type in the
python -- version
command. You will get the following output:

Figure 3
The output shown in the preceding screenshot confirms that Python has been installed successfully.
Note
Depending on your OS, Python might already be installed.
Setting up Graphviz
The following steps describe how to set up Graphviz:
- We can download the graph visualization software from https://graphviz.gitlab.io/download/.
- Since we are using Windows, we select the option that says
Stable 2.38 Windows install packages
, as shown in the following screenshot:

Figure 4
Select the .msi
downloadable file, shown as follows:

Figure 5
- Once the Graphviz executable has downloaded, go ahead and install the file with the default options; again, make a note of the path, as shown in the following screenshot:

Figure 6
- Now, we will add Graphviz's
bin
folder to the path variable, as we did when installing Python in the previous section. Then, copy the location where Graphviz is installed and append\bin
, as shown in the following screenshot:

Figure 7
- To validate whether this library has been installed properly, open a new Command Prompt window and type the
dot -V
command, and you will get the following result:

Figure 8
The output shown in the preceding screenshot confirms that Graphviz has been installed successfully.
Installing pip
The steps for installing pip
are as follows:
- To install
pip
, you need to download theget-pip.py
file from https://bootstrap.pypa.io/get-pip.py, and make a note of the path where the file is located. In my case, the file is located atDocuments\ai\softwares
. - Open the Command Prompt and go to the
Documents\ai\softwares
folder by using thecd
command, as shown in the following screenshot:

Figure 9
- Use the
dir
command to take a look at the contents of this folder, where you will seeget-pip.py
, shown in the following screenshot:

Figure 10
- Next, we'll run the
python get-pip.py
command. - Now, let's add Python's
scripts
folder to thePath
environment variable. - Open another Command Prompt window and test the installation of
pip
by typing thepip --version
command. Upon successful installation, you will get the following output:

Figure 11
- Once
pip
has installed, you can installpydot
by running the following command:
pip install pydot
- Finally, install
matplotlib
by executing the following command:
pip install matplotlib
- We can check whether the libraries have been installed properly by using the
import
command in Python's interpreter, as shown in the following screenshot:

Figure 12
Now, we're done installing the libraries that we will need in Windows for this book . In the next topic, we will look at how we can go about developing a file search application.