3.1.12 Lab - Explore Python Development Tools
3.1.12 Lab - Explore Python Development Tools
Objectives
Part 1: Launch the DEVASC VM
Part 2: Review the Python Installation
Part 3: PIP and Python Virtual Environments
Part 4: Sharing Your Virtual Environment
Background / Scenario
This course has some basic expectations for students, that they have some background in Python and some
hands-on experience with programming. Lab practice with Python gives your fingers the "muscle memory" to
work more efficiently in Python. However, initially it is important for you to know how to maintain a Python
development environment.
In this lab, you review Python installation, PIP, and Python virtual environments.
Required Resources
1 PC with operating system of your choice
Virtual Box or VMWare
DEVASC Virtual Machine
Instructions
2020 - 2025 Cisco and/or its affiliates. All rights reserved. Cisco Public Page 1 of 7 www.netacad.com
Lab - Explore Python Development Tools
b. Run the
pip3 freeze command to verify that there are no additional Python packages currently installed in the
devfun environment.
(devfun) devasc@labvm:~/labs/devnet-src/python$ pip3 freeze
(devfun) devasc@labvm:~/labs/devnet-src/python$
c. Now install the Python requests package within the devfun environment.
(devfun) devasc@labvm:~/labs/devnet-src/python$ pip3 install requests
Collecting requests
Downloading requests-2.23.0-py2.py3-none-any.whl (58 kB)
|████████████████████████████████| 58 kB 290 kB/s
Collecting urllib3!=1.25.0,!=1.25.1,<1.26,>=1.21.1
Downloading urllib3-1.25.9-py2.py3-none-any.whl (126 kB)
|████████████████████████████████| 126 kB 1.7 MB/s
Collecting idna<3,>=2.5
Downloading idna-2.9-py2.py3-none-any.whl (58 kB)
2020 - 2025 Cisco and/or its affiliates. All rights reserved. Cisco Public Page 2 of 7 www.netacad.com
Lab - Explore Python Development Tools
d. Re-enter the pip3 freeze command to see the packages now installed in the devfun environment.
Note: Your list of packages and version numbers may be slightly different.
(devfun) devasc@labvm:~/labs/devnet-src/python$ pip3 freeze
certifi==2020.4.5.1
chardet==3.0.4
idna==2.10
requests==2.24.0
urllib3==1.25.9
(devfun) devasc@labvm:~/labs/devnet-src/python$
2020 - 2025 Cisco and/or its affiliates. All rights reserved. Cisco Public Page 3 of 7 www.netacad.com
Lab - Explore Python Development Tools
e. To deactivate the virtual environment and go back to your system, enter the deactivate command.
(devfun) devasc@labvm:~/labs/devnet-src/python$ deactivate
devasc@labvm:~/labs/devnet-src/python$
2020 - 2025 Cisco and/or its affiliates. All rights reserved. Cisco Public Page 4 of 7 www.netacad.com
Lab - Explore Python Development Tools
b. Send the output of the pip3 freeze command to a text file called requirements.txt.
(devfun) devasc@labvm:~/labs/devnet-src/python$ pip3 freeze > requirements.txt
c. Deactivate the devfun virtual environment. You can use the ls command to see that the
requirements.txt file is in the /python directory.
(devfun) devasc@labvm:~/labs/devnet-src/python$ deactivate
devasc@labvm:~/labs/devnet-src/python$ ls
devfun file-access-input.py if-acl.py requirements.txt
devices.txt file-access.py if-vlan.py while-loop.py
devnew hello-world.py person-info.py
2020 - 2025 Cisco and/or its affiliates. All rights reserved. Cisco Public Page 5 of 7 www.netacad.com
Lab - Explore Python Development Tools
g. When entering pip3 freeze in the devnew environment, you should see the following output.
(devnew) devasc@labvm:~/labs/devnet-src/python$ pip3 freeze
certifi==2020.4.5.1
chardet==3.0.4
idna==2.9
pkg-resources==0.0.0
2020 - 2025 Cisco and/or its affiliates. All rights reserved. Cisco Public Page 6 of 7 www.netacad.com
Lab - Explore Python Development Tools
requests==2.23.0
urllib3==1.25.9
(devnew) devasc@labvm:~/labs/devnet-src/python$
h. D
ea
cti
va
te
2020 - 2025 Cisco and/or its affiliates. All rights reserved. Cisco Public Page 7 of 7 www.netacad.com