Python (Scripting) - Installing packages in a virtual environment

by
Jeremy Canfield |
Updated: August 25 2020
| Python (Scripting) articles
This assumes you have created a virtual environment and have also activated the virtual environment. In this example, a virtual environment named foo was created and activated. Let's say the virtual environment only contains pip and setuptools.
(foo) [~#]$ pip3 list
pip (9.0.3)
setuptools (39.2.0)
In this example, you are using ~/foo/bin/pip3 inside of the virtual environment. Here is how to install the "requests" package inside of the virtual environment.
(foo) [~#]$ pip3 install requests
Now, the "requests" package has been installed in the virtual environment.
(foo) [~#]$ pip3 list
certifi (2020.6.20)
chardet (3.0.4)
idna (2.10)
pip (9.0.3)
requests (2.24.0)
setuptools (39.2.0)
urllib3 (1.25.10)
If you deactivate to leave the virtual environment . . .
(foo) [~#]$ deactivate
. . . you can see that "requests" was not installed in the normal installation of pip3.
[~#]$ pip3 list
pip (9.0.3)
setuptools (39.2.0)
Did you find this article helpful?
If so, consider buying me a coffee over at