Python @ DjangoSpin

Python: Installing external modules using pip

Buffer this pageShare on FacebookPrint this pageTweet about this on TwitterShare on Google+Share on LinkedInShare on StumbleUpon
Reading Time: 2 minutes

pip in Python

pip in Python

Python comes with many useful modules out-of-the-box. In addition to these modules, there is a large library of third-party modules which Python developers have distributed for fellow developers to use. These modules are listed in Python Package Index (PyPI), also known as the Cheese Shop, with a reference to Monty Python's Flying Circus, the TV show after which the language was named. These external modules come in wheel files (.whl) or executables (.exe). Wheel files can be installed using pip.

pip is Python's package management system, and is shipped with the installation in versions 2.7.9+ & 3.4+. This decision of including a package manager with the standard installation was welcome graciously by the Python community, as it spared them the hassles of setting up a package manager themselves. This puts Python in a bracket of programming languages which ship their package manager with standard installations, such as Haskell, Ruby, Node.js. The word pip is a recursive acronym that is interpreted to mean either "Pip installs Python" or "Pip installs Packages".

For Python versions 2 - 2.7.8 & 3 - 3.3, you will have to save this page as in your system, and then run it using command-prompt (in Administrator mode) i.e. $ python, ensuring you are in the current directory.

Before pip, a builtin Python module called easy_install was used to install third-party modules. In fact, in versions mentioned above, it is still used to install third-party modules.

# Installing a .whl using pip
# Command Prompt/Terminal
$ pip install file_name.whl

# Installing an external module directly using pip. The mentioned module must be present in the Cheese Shop.
$ pip install cx_Oracle

# In case you get a .exe file from PyPI instead of a .whl file, you can execute the .exe files directly without using Python.
If pip is not working, it might be due to the fact that it is not in your path environment variable. One workaround for this issue is to run pip as a script by using the -m flag of python command line.

$ python -m pip install cx_Oracle

There are chances that you might receive an error while installing these modules. This could either be due to the 32/64 bit operating system issue, or the language version incompatibility or some other reason. In these events, Google the error, since it is very likely that the same error could have been encountered by fellow Python developers.

See also:

Buffer this pageShare on FacebookPrint this pageTweet about this on TwitterShare on Google+Share on LinkedInShare on StumbleUpon

Leave a Reply