How to Use PyPI & PIP

Reading Time: 3 minutes
pypi logo

In this article, we will discuss how to access and utilize the Python Package Index or PyPI via the pip command.

PyPI is the default software repository for Python developers to store created Python programming language software developers and programmers alike use to publicize and share their software.

Along with PyPI, the PyPi-Install library enables you to upload Python code to PyPI using just using a single function call. After utilizing this option, you can install a Python library from any terminal using the popular command:

root@host [~]# pip install mylibary 

PyPI itself also simplifies the Python packaging process for Python programs. The specific packaging process is noted here.

Is PyPI’s Content Open Source?

The Python code that is shared is all open source. The PyPI website states:

“PyPI does not support publishing private packages. If you need to publish your private package to a package index, the recommended solution is to run your own deployment of the devpi project.

https://lqwb.us/33IvL6e

One thing of note; The PyPi-Install library only attempts to streamline the packaging process noted on the official website. Additionally, if you want to know more about PyPI, head over to their homepage.

Access PyPI

The next section covers the basics of how to install Python “packages”. It’s important to note that the term “package” used in this context serves as a synonym for a distribution. A distribution is a collection of packaged software that includes all of the modules and other resources needed to install and run a Python package.

This does not refer to the sort of package that you introduce into your Python source code (i.e., a container of modules). It is standard in the Python community to refer to a distribution as a “package”. We limit the use of the term “distribution” simply because as it is too easily mixed-up with a Linux distribution or another more significant software releases like Python itself.

Given that Ubuntu 18.04 comes with Python 3 as the default install of Python, we can complete the following steps to deploy PIP (actually pip3) for Python 3. We can start by updating Ubuntu’s package list using the following command:

root@host:~# apt update

Next, we’ll use the following command to install PIP for Python 3:

root@host:~# apt install python3-pip

This command will also install all the dependencies needed for building Python modules. 

Once the install is complete, we can verify the installation by running the following command to check the version of PIP we installed. Remember, the version number may vary, but it will look something like this:

root@host:~# pip3 --version
 pip 9.0.1 from /usr/lib/python3/dist-packages (python 3.6)
 root@host:~#

PIP PIP ‘Old Chap!

We touched on the PIP command in earlier articles in the Liquid Web Knowledge Base, which in essence, states that PIP “is a tool for installing and managing packages for Python. It is one of the easiest tools to use in manipulating binary packages designed for Python”.

With PIP, we can use either a virtual environment to test out programs or use it in a global setting on a server. PIP is often used in a virtual setting (using venv) to limit the interactions between the test project’s dependencies and the operating system’s default Python environment.

PIP is also tightly linked to PyPI for creating Python packages, as noted in the Python Packaging Guide. Because PIP is updated quarterly, its lifecycle is considered very active and millions of Python users and developers rely on it daily as part of a more extensive Python infrastructure.

If you do not have PIP installed, you can download it here: get-pip.py

Install PIP

To install PIP  on your server, run:

root@host [~]# wget https://bootstrap.pypa.io/get-pip.py 

Then, run

root@host [~]# python get-pip.py 

This command will install or upgrade PIP. Additionally, it will install the setuptools and wheel programs if they’re not installed already. Setuptools is a group of improvements to the Python distutils that allows us to easily build and share Python distributions, especially the ones that have dependencies that rely on other packages. The wheel extension is used for creating wheel formatted distribution.

What Is Setuptools & Wheel Programs

Setuptools is a group of improvements to the Python distutils that allow us to easily build and share Python distributions, especially the ones that have dependencies that on rely on other packages. The wheel extension is used for creating wheel formatted distribution. 

Update Everything

Running the following command will ensure you have the latest version of everything needed to use PyPI:

root@host [~]# python3 -m pip install --upgrade pip setuptools wheel

We Can’t Wait To Hear From You!

Utilizing Python, one of the hottest languages in programming today, will allow you to stay far ahead of your competition. Liquid Web can help you achieve the edge you need to stay on top of your game! Reach out to us today to see how we can leverage your platform along with our state of the art systems to gain market share over your competitors

Give us a call today at 800.580.4985, or open a chat or ticket with us to speak with one of our knowledgeable Solutions or Hosting advisors today!

Author Bio

About the Author: David Singer

I am a g33k, Linux blogger, developer, student and Tech Writer for Liquidweb.com/kb. My passion for all things tech drives my hunt for all the coolz. I often need a vacation after I get back from vacation....

Get 33% off the first 3 months on a new Dedicated server! Find out why 30,000 customers have chosen our Best-in-Class Performance & 24x7x365 Support