Search icon CANCEL
Arrow left icon
Explore Products
Best Sellers
New Releases
Books
Videos
Audiobooks
Learning Hub
Conferences
Free Learning
Arrow right icon
Arrow up icon
GO TO TOP
Mastering Python Networking

You're reading from   Mastering Python Networking Utilize Python packages and frameworks for network automation, monitoring, cloud, and management

Arrow left icon
Product type Paperback
Published in Jan 2023
Publisher Packt
ISBN-13 9781803234618
Length 594 pages
Edition 4th Edition
Languages
Tools
Arrow right icon
Author (1):
Arrow left icon
Eric Chou Eric Chou
Author Profile Icon Eric Chou
Eric Chou
Arrow right icon
View More author details
Toc

Table of Contents (19) Chapters Close

Preface 1. Review of TCP/IP Protocol Suite and Python 2. Low-Level Network Device Interactions FREE CHAPTER 3. APIs and Intent-Driven Networking 4. The Python Automation Framework – Ansible 5. Docker Containers for Network Engineers 6. Network Security with Python 7. Network Monitoring with Python – Part 1 8. Network Monitoring with Python – Part 2 9. Building Network Web Services with Python 10. Introduction to Async IO 11. AWS Cloud Networking 12. Azure Cloud Networking 13. Network Data Analysis with Elastic Stack 14. Working with Git 15. Continuous Integration with GitLab 16. Test-Driven Development for Networks 17. Other Books You May Enjoy
18. Index

Python virtual environment

Let us start by using the Python virtual environment. The Python virtual environment allows us to manage separate package installations for different projects by creating a “virtual” isolated Python installation and installing packages into that virtual installation. By using a virtual environment, we do not need to worry about breaking the packages installed globally or from other virtual environments. We will start by installing the python3.10-venv package, then create the virtual environment itself:

$ sudo apt update
$ sudo apt install python3.10-venv
$ python3 -m venv venv 
$ source venv/bin/activate
(venv) $
(venv) $ deactivate

From the output, we saw that we use the venv module from our installation, create a virtual environment called “venv” and then activate it. While the virtual environment is activated, you will see the (venv) label in front of your hostname, indicating that you are in that virtual environment. When finished, you can use the deactivate command to exit the virtual environment. If interested, you can learn more about Python virtual environments here: https://packaging.python.org/guides/installing-using-pip-and-virtual-environments/#installing-virtualenv.

Always activate the virtual environment before you work on the code to isolate environments.

Once we have activated the virtual environment, we can move on to install the Pexpect library.

You have been reading a chapter from
Mastering Python Networking - Fourth Edition
Published in: Jan 2023
Publisher: Packt
ISBN-13: 9781803234618
Register for a free Packt account to unlock a world of extra content!
A free Packt account unlocks extra newsletters, articles, discounted offers, and much more. Start advancing your knowledge today.
Unlock this book and the full library FREE for 7 days
Get unlimited access to 7000+ expert-authored eBooks and videos courses covering every tech area you can think of
Renews at R$50/month. Cancel anytime