Lecture # 16 - Packages, PyPI, and pip

Packages:

Python comes with some built-in packages. There are many more packages out there, but they are not part of python installation. Such packages are called third-party packages. If you want to use the third-party packages you'll need to install them first.

Packages vs Modules:

  • Any python file is a module.

  • Package is a collection of python modules.

  • Package must include an __init__.py file.

  • This __init__.py file distinguishes a package from a directory.

PyPI:

PyPI is known as Python Package Index. PyPI is a repository for third-party packages. People can also publish their own package to this repository. There are over 290,000 python packages in PyPI. Click Here to open PyPI.

You can search the package that you want to install. e.g. search a package numpy.

pip:

pip is a package manager for python. pip is used to install packages from the PyPI, and also other indexes. pip is included in the python installation. To use pip you'll have to open the terminal of the IDE that you're using.

Installing a Package:

To install a package pip install [package-name] is used.

List the Installed Packages:

To list the installed packages pip list is used.

Show Package Information:

To see the installed package information pip show [package-name] is used.

Install Specific Version of a Package:

To install a specific version of a package pip install [package-name]==[version] is used.

Upgrade a Package:

To upgrade a package pip install --upgrade [package-name] is used.

Delete a Package:

To delete a package pip uninstall [package-name] is used.

0
Subscribe to my newsletter

Read articles from Abdullah Bin Altaf directly inside your inbox. Subscribe to the newsletter, and don't miss out.

Written by

Abdullah Bin Altaf
Abdullah Bin Altaf