Archive for the ‘python’ Category

python: pip

July 31, 2017

The post discusses pip, package manager of python.

environment

bash-3.2$ sw_vers
ProductName:    Mac OS X
ProductVersion: 10.11.6
BuildVersion:   15G1510
bash-3.2$ python --version
Python 2.7.10

install pip
Use easy_install to install pip.

bash-3.2$ sudo easy_install pip
Password:
Searching for pip
Reading https://pypi.python.org/simple/pip/
Best match: pip 9.0.1
Downloading https://pypi.python.org/packages/11/b6/abcb525026a4be042b486df43905d6893fb04f05aac21c32c638e939e447/pip-9.0.1.tar.gz#md5=35f01da33009719497f01a4ba69d63c9
Processing pip-9.0.1.tar.gz
Writing /tmp/easy_install-vuf8Jk/pip-9.0.1/setup.cfg
Running pip-9.0.1/setup.py -q bdist_egg --dist-dir /tmp/easy_install-vuf8Jk/pip-9.0.1/egg-dist-tmp-mPnzBX
/System/Library/Frameworks/Python.framework/Versions/2.7/lib/python2.7/distutils/dist.py:267: UserWarning: Unknown distribution option: 'python_requires'
  warnings.warn(msg)
warning: no previously-included files found matching '.coveragerc'
warning: no previously-included files found matching '.mailmap'
warning: no previously-included files found matching '.travis.yml'
warning: no previously-included files found matching '.landscape.yml'
warning: no previously-included files found matching 'pip/_vendor/Makefile'
warning: no previously-included files found matching 'tox.ini'
warning: no previously-included files found matching 'dev-requirements.txt'
warning: no previously-included files found matching 'appveyor.yml'
no previously-included directories found matching '.github'
no previously-included directories found matching '.travis'
no previously-included directories found matching 'docs/_build'
no previously-included directories found matching 'contrib'
no previously-included directories found matching 'tasks'
no previously-included directories found matching 'tests'
Adding pip 9.0.1 to easy-install.pth file
Installing pip script to /usr/local/bin
Installing pip2.7 script to /usr/local/bin
Installing pip2 script to /usr/local/bin

Installed /Library/Python/2.7/site-packages/pip-9.0.1-py2.7.egg
Processing dependencies for pip
Finished processing dependencies for pip
bash-3.2$ pip --version
pip 9.0.1 from /Library/Python/2.7/site-packages/pip-9.0.1-py2.7.egg (python 2.7)

find python packages in PyPI
PyPI, python package index, has more than 100,000 python packages. Each package can be installed with two methods.

  • Install it with pip
  • bash-3.2$ pip install package_name
    
  • Download the tarball, unpack, and then install it
  • bash-3.2$ python setup.py install
    

basic pip commands

  • list installed packages
  • bash-3.2$ pip list
    
  • install packages
  • bash-3.2$ pip install package_name
    
  • uninstall packages
  • bash-3.2$ pip uninstall package_name
    

conclusion
The post shows how to intall pip, how to find python packages, and basic pip commands.

Advertisements

%d bloggers like this: