Pip is a package manager for Python and can be accessed through the command line. Pip does not need to be installed separately if you are using Python 2.7.9 or later, or 3.4 or later. If pip is installed, then you can enter in the command line:
pip
The commands in this article are for Windows, pip work in Linux may differ.
You will get help with basic commands.
Install pip for Python
If pip is not installed, then you need to download the script . Select the folder with your Python version number. After that, in the command line, go to the folder with the script and run the command:
python get-pip.py
If pip is installed in the ProgramFiles folder, then you need to run command line as administrator.
If you installed pip but still get an error in the console, you need to specify the path to the pip.exe file in the Path variable. To do this, go to Computer Properties> Advanced System Settings> Environment Variables. Here (depending on the Windows version), either add the path to the already existing one separated by semicolons, or just click New and copy the path into a new field.
If you need to upgrade pip write on the command line:
python -m pip install --upgrade pip
Package management
To install a package from pypi.org, enter in the console:
python -m pip install ИмяПакета
If you need to use several versions of pip, then the one you need can be specified like this (starting from version pip 0.8):
pip-0.8 install ИмяПакета
You can select the Python version in the same way:
python-3.6 -m pip install ИмяПакета
Pip version 1.5 and higher should be specified like this:
pip2.6 install ИмяПакета
To update the package enter:
python -m pip install --upgrade ИмяПакета
To uninstall a package, use the uninstall command:
python -m pip uninstall ИмяПакета
The -m flag is used to run the installed module as a script (if you write pip without -m you may get an error).
You can display a list of all installed packages to a file using:
pip freeze > requirements.txt // название файла может быть любым
If there is such a file, you can install packages in groups:
pip install -r requirements.txt// версии пакетов в файле указывать не обязательно
The required packages can be found without going to pyPi.org (currently not available ):
pip search строка для поиска
To find out the details of an installed package, enter:
pip show ИмяПакета
You can check if all the dependencies for your packages are installed like this:
pip check
Now, with this knowledge, you can download the cowsay package yourself, go into python, and enter this text:
>>> import cowsay
>>> cowsay.cow('Я умею работать с pip! Му!')
Ready! You have a talking console cow: