
The pip list command will display the packages that have been installed using pip. In this example, pip will attempt to install packages into Python version 3.9.6.
~]$ pip list -v
Package Version Location Installer
------------ ------- ------------------------------------------------------ ---------
bcrypt 4.0.1 /usr/local/bin/python3.9.6/lib/python3.9/site-packages pip
cffi 1.16.0 /usr/local/bin/python3.9.6/lib/python3.9/site-packages pip
cryptography 41.0.5 /usr/local/bin/python3.9.6/lib/python3.9/site-packages pip
paramiko 3.3.1 /usr/local/bin/python3.9.6/lib/python3.9/site-packages pip
pip 21.1.3 /usr/local/bin/python3.9.6/lib/python3.9/site-packages pip
pycparser 2.21 /usr/local/bin/python3.9.6/lib/python3.9/site-packages pip
PyNaCl 1.5.0 /usr/local/bin/python3.9.6/lib/python3.9/site-packages pip
setuptools 56.0.0 /usr/local/bin/python3.9.6/lib/python3.9/site-packages pip
The pip install command can be used to install a package.
]$ pip install jsonpatch
Defaulting to user installation because normal site-packages is not writeable
Collecting jsonpatch
Downloading jsonpatch-1.32-py2.py3-none-any.whl (12 kB)
Collecting jsonpointer>=1.9
Downloading jsonpointer-2.3-py2.py3-none-any.whl (7.8 kB)
Installing collected packages: jsonpointer, jsonpatch
Successfully installed jsonpatch-1.32 jsonpointer-2.3
Or, you can list the packages that you want installed in a file, typically named requirements.txt.
jsonpatch==1.32
And then use the pip install command with the -r or --requirement option.
pip install --requirement requirement.txt
The following can be used if you want to install a package in a specific version of Python.
/usr/bin/python3.6 -m pip install paramiko
And here is how you could install a module from GitHub. Check out my article Python (Scripting) - Creating your own module in GitHub.
~]$ pip install git+ssh://git@github.com/JohnDoe/modules.git#egg=greeting
Collecting my_pip_package
Cloning ssh://****@github.com/JohnDoe/modules.git to /tmp/pip-install-i90pj1zy/greeting_c45c7fff3cc64315b04864072b6c0470
Running command git clone -q 'ssh://****@github.com/JohnDoe/modules.git' /tmp/pip-install-i90pj1zy/greeting_c45c7fff3cc64315b04864072b6c0470
Using legacy 'setup.py install' for greeting, since package 'wheel' is not installed.
Installing collected packages: greeting
Running setup.py install for greeting ... done
Successfully installed greeting-0.0.1
When you install a package using pip, one or more files and directories get installed to the site-packages folder. For example, if you install paramiko in Python version 3.9.6 using pip then there should be one or more paramiko files and directories in the Python 3.9.6 site-packages directory.
/usr/local/bin/python3.9.6/lib/python3.9/site-packages/paramiko
Did you find this article helpful?
If so, consider buying me a coffee over at