07.07.2023 Views

Implementing-cryptography-using-python

You also want an ePaper? Increase the reach of your titles

YUMPU automatically turns print PDFs into web optimized ePapers that Google loves.

6 Chapter 1 ■ Introduction to Cryptography and Python

Installing Pip, NumPy, and Matplotlib

Ensure you are in a command shell environment with a prompt. In the following

example installation, you will get an update to the packages that come with

your Python version.

Pip, or Pip3 in this case, is the package management system for Python; it is

used to install and manage software packages written in Python. Pip is similar

to tools like Bundle, NPM, and Composer in other programming languages.

NumPy, which stands for Numerical Python, is a Python package that is the

core library for scientific computing. It contains a powerful n-dimensional array

object, and provides tools for integrating C, C++, and many other languages.

Matplotlib is an excellent solution for scientific plotting; it has the ability to be

automated and produce a wide variety of customizable high-quality plots.

Once the shell is open, type the following commands:

~$ sudo apt-get update

~$ sudo apt install python-pip

~$ pip3 install numpy

~$ pip3 install matplotlib

~$ $ python3 -c "import numpy as np; import matplotlib.pyplot as plt; x

= np.linspace(0, 2 * np.pi); y = np.sin(x); plt.plot(x, y); plt.show()"

NOTE Depending on your environment, you may need to install python3-pip to

get Pip3 to work. On installs such as Ubuntu 16.04 on Windows, you will not be able to

install version 3 when you install python-pip.

To start the Python 3 shell, type the following:

~$ python3

You should see something similar to the following depending on the version

that is installed:

Python 3.X.X (default, date)

[GCC 6.3.0 20170516] on linux

Type "help", "copyright", "credits" or "license" for more information.

>>>

To test whether you have the additional packages installed correctly, open

your favorite Python editor. If you don’t have one, you can elect to use Nano in

a Linux environment or even Notepad in a Windows environment. Type the

following:

#!/usr/bin/env python

import numpy as np

Hooray! Your file is uploaded and ready to be published.

Saved successfully!

Ooh no, something went wrong!