У Python имеется собственный “репозиторий” различных пакетов – PyPI (Python Package Index).
Для работы с ним имеется замечательная утилита – pip
.
Устанавливаем.
Для FreeBSD:
# make search key="Python packages" Port: py27-pip-1.5.2 Path: /usr/ports/devel/py-pip Info: Tool for installing and managing Python packages Maint: [email protected] B-deps: gettext-0.18.3.1 libiconv-1.14_3 py27-setuptools27-2.0.1 python27-2.7.6_4 readline-6.3.3_1 R-deps: gettext-0.18.3.1 libiconv-1.14_3 py27-setuptools27-2.0.1 python27-2.7.6_4 readline-6.3.3_1 WWW: http://pip-installer.org/
# cd /usr/ports/devel/py-pip && make install clean
Для CentOS:
# yum -y install python-pip
После установки опцией -h
можно вывести справку по утилите:
# pip -h Usage: pip <command> [options] Commands: install Install packages. uninstall Uninstall packages. freeze Output installed packages in requirements format. list List installed packages. show Show information about installed packages. search Search PyPI for packages. wheel Build wheels from your requirements. zip DEPRECATED. Zip individual packages. unzip DEPRECATED. Unzip individual packages. bundle DEPRECATED. Create pybundles. help Show help for commands. General Options: -h, --help Show help. -v, --verbose Give more output. Option is additive, and can be used up to 3 times. -V, --version Show version and exit. -q, --quiet Give less output. --log-file <path> Path to a verbose non-appending log, that only logs failures. This log is active by default at /root/.pip/pip.log. --log <path> Path to a verbose appending log. This log is inactive by default. --proxy <proxy> Specify a proxy in the form [user:passwd@]proxy.server:port. --timeout <sec> Set the socket timeout (default 15 seconds). --exists-action <action> Default action when a path already exists: (s)witch, (i)gnore, (w)ipe, (b)ackup. --cert <path> Path to alternate CA bundle.
Например – установим пакет wget:
# pip install wget Downloading/unpacking wget Downloading wget-2.0.tar.gz Running setup.py (path:/tmp/pip_build_root/wget/setup.py) egg_info for package wget Installing collected packages: wget Running setup.py install for wget Could not find .egg-info directory in install record for wget Successfully installed wget Cleaning up...
Или – удалим его:
# pip uninstall wget Uninstalling wget: /usr/local/lib/python2.7/site-packages/wget-2.0-py2.7.egg-info /usr/local/lib/python2.7/site-packages/wget.py /usr/local/lib/python2.7/site-packages/wget.pyc Proceed (y/n)? y Successfully uninstalled wget
Посмотреть список уже установленных пакетов для Python:
# pip list Babel (1.3) docutils (0.11) Jinja2 (2.7.2) MarkupSafe (0.19) pip (1.5.2) Pygments (1.6) pytz (2014.1.1) setuptools (2.0.1) Sphinx (1.2.2) wget (2.0) wsgiref (0.1.2)
И посмотреть информацию по установленному пакету:
# pip show Sphinx --- Name: Sphinx Version: 1.2.2 Location: /usr/local/lib/python2.7/site-packages/Sphinx-1.2.2-py2.7.egg Requires: Pygments, docutils, Jinja2
Поиск пакета по ключевому слову:
# pip search netstat Cownet - I wanted to view my up to date network usage in a easy to read and friendly way. So I built a tool that pulls the data in from netstat, and displays a cleaned up output in Cowsay. hardscan - Utility to detect open ports if netstat may be compromised pynetstat - python module parse netstat command output into list of namedtuple:inet_connection
Ссылки по теме
http://www.pip-installer.org
https://python-packaging-user-guide.readthedocs.org
https://pypi.python.org