Pip and conda command quick reference - perrigoh/learner_journal GitHub Wiki
WIP: Usable
Full pip documentation refer here.
Python version 3.4 and above has ensurepip
module as a standard library which will install pip automatically. For cases where pip is not installed, refer here for the installation information.
$ pip --version
# or
$ python -m pip --version
pip 22.3.1 from C:...\Python39\site-packages\pip (python 3.9)
If the installed python earliest version is 3 above, using python
or python3
has no difference.
$ pip install --upgrade pip
# or
$ python -m pip install --upgrade pip
Requirement already satisfied: pip in c:...\python39\site-packages (22.3.1)
Refer here for options available and examples:
```bash
$ pip install numpy
# or
python -m pip install numpy
Collecting numpy
Downloading numpy-1.23.5-cp39-cp39-win_amd64.whl (14.7 MB)
...
Successfully installed numpy-1.23.5
```
$ pip list
# or
$ python -m pip list
Package Version
--------------------------------- -----------
analytics-python 1.4.0
anyio 3.6.1
argon2-cffi 21.3.0
...
zipp 3.8.0
There are options to list outdated package python -m pip list --outdated
, list packages that are not dependencies of other packages python -m pip list --not-required
and more, refer here for all the options and examples.
Show information of specific package:
$ pip show matplotlib
# or
$ python -m pip show --verbose matplotlib
Name: matplotlib
Version: 3.5.2
Summary: Python plotting package
Home-page: https://matplotlib.org
Author: John D. Hunter, Michael Droettboom
Author-email: [email protected]
License: PSF
Location: c:...\python39\site-packages
Requires: cycler, fonttools, kiwisolver, numpy, packaging, pillow, pyparsing, python-dateutil
Required-by: seaborn
Show all information of specific package:
$ pip show --verbose matplotlib
# or
$ python -m pip show --verbose matplotlib
Name: matplotlib
Version: 3.5.2
Summary: Python plotting package
Home-page: https://matplotlib.org
Author: John D. Hunter, Michael Droettboom
Author-email: [email protected]
License: PSF
Location: c:...\python39\site-packages
Requires: cycler, fonttools, kiwisolver, numpy, packaging, pillow, pyparsing, python-dateutil
Required-by: seaborn
Metadata-Version: 2.1
Installer: pip
Classifiers:
Development Status :: 5 - Production/Stable
Framework :: Matplotlib
Intended Audience :: Science/Research
Intended Audience :: Education
License :: OSI Approved :: Python Software Foundation License
Programming Language :: Python
Programming Language :: Python :: 3
Programming Language :: Python :: 3.7
Programming Language :: Python :: 3.8
Programming Language :: Python :: 3.9
Programming Language :: Python :: 3.10
Topic :: Scientific/Engineering :: Visualization
Entry-points:
Project-URLs:
Documentation, https://matplotlib.org
Source Code, https://github.com/matplotlib/matplotlib
Bug Tracker, https://github.com/matplotlib/matplotlib/issues
Forum, https://discourse.matplotlib.org/
Donate, https://numfocus.org/donate-to-matplotlib
Show files specific package:
-f
= --files
$ pip show -f matplotlib
# or
$ python -m pip show -f matplotlib
Name: matplotlib
Version: 3.5.2
Summary: Python plotting package
Home-page: https://matplotlib.org
Author: John D. Hunter, Michael Droettboom
Author-email: [email protected]
License: PSF
Location: c:\users\wmxpg\appdata\local\packages\pythonsoftwarefoundation.python.3.9_qbz5n2kfra8p0\localcache\local-packages\python39\site-packages
Requires: cycler, fonttools, kiwisolver, numpy, packaging, pillow, pyparsing, python-dateutil
Required-by: seaborn
Files:
__pycache__\pylab.cpython-39.pyc
matplotlib-3.5.2-py3.9-nspkg.pth
matplotlib-3.5.2.dist-info\INSTALLER
matplotlib-3.5.2.dist-info\LICENSE
matplotlib-3.5.2.dist-info\LICENSE_AMSFONTS
matplotlib-3.5.2.dist-info\LICENSE_BAKOMA
...
mpl_toolkits\tests\test_axisartist_grid_helper_curvelinear.py
mpl_toolkits\tests\test_mplot3d.py
pylab.py
Use pip freeze -l
or pip freeze --local
for exporting only local installed packages and pip freeze --all
to include setuptools, distribute, wheel and pip.
Refer here for all options available and examples.
This method only lists the packages, it does not create requirements text file (requirements.txt):
$ pip freeze
# or
$ python -m pip freeze
analytics-python==1.4.0
anyio==3.6.1
argon2-cffi==21.3.0
...
XlsxWriter==3.0.2
zipp==3.8.0
To create requirements text file (requirements.txt):
$ pip freeze > requirements.txt
# or
$ python -m pip freeze > requirements.txt
NO OUTPUT
The requirements.txt file will be created and save in the currently working directory (folder).
Steps:
-
Change directory to the directory (folder) where the requirements.txt file is stored, in this use case the file is store in project_webapp directory (folder):
$ cd virtual_env/project_webapp/ NO OUTPUT
The prompt will change to from
[wmxpg] ~
to[wmxpg] ~/virtual_env/project_webapp
-
Install the requirements.
-r
=--requirement
:$ pip install -r requirements.txt Collecting numpy==1.23.5 Downloading numpy-1.23.5-cp311-cp311-win_amd64.whl (14.6 MB) ... Successfully installed numpy-1.23.5
-
Check the package has been installed:
$ pip list Package Version ---------- ------- numpy 1.23.5 pip 22.1.2 setuptools 62.6.0 wheel 0.37.1
TODO
https://pip.pypa.io/en/stable/cli/pip_check/
https://pip.pypa.io/en/stable/user_guide/
https://pip.pypa.io/en/stable/installation/
How do I Update PIP to Latest Version & Check if PIP Package is Installed - https://linuxhint.com/check-update-pip-latest-version/
The PIP is a cross-platform, written in Python to install and manage Python packages from the Python Package Index and from additional libraries (local and remote) that are not part of standard repositories.
How do I Update PIP to Latest Version To upgrade the PIP package, the command is quite simple. Type the following command in the terminal: pip install --upgrade pip
How do you check if a PIP Package is Installed To check if pip is already available on the system, the simplest way is to use the version option, and it will show the current version of the PIP package. So, open the terminal and type: pip --version
There are two approaches to check the installed PIP modules: Through the “pip list” command Through the “pip freeze” command
Check what PIP modules are Installed through the “PIP list” Command The list option will display the list of all the installed modules, including their versions on the system: pip list
Check what PIP modules are Installed through the “PIP freeze” Command The “PIP freeze” command is another way to find how many modules have been installed using the PIP package. To get it, type: pip freeze
Steps:
-
To update all the PIP modules, firstly redirect all the modules name to a text file using the “Freeze” command:
$ pip freeze > pip_modules.txt TODO: NO EXAMPLE AT THE MOMENT
-
Run the following command to update all of them:
$ pip install –r pip_modules.txt --upgrade TODO: NO EXAMPLE AT THE MOMENT
$ pip list | grep mkdocs
# or
$ pip list | findstr mkdocs
mkdocs 1.4.2
$ pip --version
# or
$ pip3 --version
pip 22.3.1 from C:\...local-packages\Python39\site-packages\pip (python 3.9)