A Guide to Using the Python Package Manager PIP on OpenBSD

A Guide to Using the Python Package Manager PIP on OpenBSD


Modern software developers are increasingly faced with the challenge of managing the many libraries and tools needed to work effectively and efficiently. In Python-based programming, this task can be accomplished by using a dedicated package manager. This tool can simplify and manipulate the various packages and their versions in a project.

Python, like any other programming language, supports additional (third-party) frameworks and libraries. These libraries are installed by developers with the simple goal of making their work easier and not repeating new projects every time. The required packages are located on PyPI, which can be called the central Python repository and Python Package Index.

In this article I wrote on publish0x, we will learn the process of installing, configuring and using the Python PIP package on the OpenBSD 7.6 system.

A. What is PIP?

The abbreviation PIP itself is a recursive acronym. Basically, PIP is a package management system. This system is used to install and manage software packages written in the Python programming language. PIP is also often referred to as the preferred program installer. And directly PIP is a command that runs related utilities to install, reinstall, and uninstall packages contained in PyPI.

PIP is a package manager. PIP allows you to install and manage Python packages that you can use from the command line. PIP has a number of advantages:

  • the tool is easy to install and use. Thanks to it, developers do not need to manually download and manage dependencies.
  • PIP has access to a large repository that consists of both popular packages and lesser-known ones.
  • the service allows you to manage versions of installed packages, which makes it easier to update them.
  • there is an automatic installation of dependencies required for packages.
  • PIP can be integrated with virtualenv and conda, making it easier to manage the Python environment.
  • Cross-platform compatibility-the manager is compatible with several operating systems, including Windows, macOS, and Linux.

B. System specifications:

OS: OpenBSD 7.6-current amd64
Host: Acer Aspire M1800
CPU: Intel Core 2 Duo E8400 (2) @ 3.000GHz
Memory: 181MiB / 1775MiB
IP Address: 192.168.5.3
Hostname: ns3
Versi Python: python-3.11.10p0
Versi PIP: py-pip-20.3.4p3

 

C. Install Python-3.11

 

Because PIP is used to make it easier to install Python packages, the main requirement for PIP to be used is that you must install Python.

ns5# pkg_add python-3.11.10p0
ns5# pkg_add py-setuptools-44.1.1p0v0
or
ns5# pkg_add python-3.11.10p1
ns5# pkg_add py-setuptools-44.1.1p0v0
 

1. Create Python-3.11 Symlink

Because there are so many python repositories in OpenBSD that will indirectly be installed when you install one of the programs. So to make sure which version of Python you are using, you have to create a symlink.

ns5# ln -s /usr/local/bin/python3.11 /usr/local/bin/python

2. Checking Python Version

This part is very important, not only to check the python version, but also to make sure whether Python has been installed or not on OpenBSD.

ns5# python --version
Python 3.11.10

 

D. Installing PIP

 

Pip is a special program used to install Python packages onto your system. PIP is sometimes included automatically when Python is installed on your system, and sometimes you have to install it yourself. However, on OpenBSD systems, you must install PIP manually. This guide will help you install PIP on OpenBSD.

ns5# pkg_add -i py-pip

 

1. Create PIP Symlink

 

Similar to Python programs, you also need to create a symlink for PIP.

ns5# ln -sf /usr/local/bin/pip2.7 /usr/local/bin/pip

 

2. Checking PIP Version

 

The next step is almost the same as the Python program, we continue by checking the PIP version.

ns5# pip --version

 

E. Installing Python Packages with PIP

 

Once the PIP installation is complete, pip is installed and ready to use. As a result, we can start installing packages using PIP from PyPI. Most Python packages can be installed in a single command line. For example, here's how to install Requests, which is used to make API calls from Python programs.

ns5# pip install --user requests

In the example script above, PIP has downloaded the files needed to install Requests, and then managed the installation for us. The --user flag means that pip has made Requests available to us, but not to other users. This prevents individual Python packages from conflicting with each other on a multi-user system. It’s a good idea to use this flag unless you have a specific reason not to.

 

1. Removing Python packages with pip

 

If you want to remove a Python installation package, you can use the request to do the removal as in the following example.

ns5# pip uninstall requests

 

2. How to Update PIP

 

Once PIP is installed, it is a good idea to update it from time to time. Usually pip will prompt you with instructions on how to update it when necessary, but you can try updating it manually at any time. For example, here is an example of the output for updating an older version of pip.

ns5# pip install --upgrade pip

Actually, if you want to use Pip to install Python-based GUI applications, you should use Pipx. Pip complies with the new Python guidelines. But this article does not discuss PIPX, you can read other articles that discuss PIPX.

How do you rate this article?

5


BSD Blockchain
BSD Blockchain

https://unixwinbsd.site


Linux BSD Blockchain
Linux BSD Blockchain

Opensource Blog (FreeBSD, Linux, OpenBSD) For Blockchain Network

Publish0x

Send a $0.01 microtip in crypto to the author, and earn yourself as you read!

20% to author / 80% to me.
We pay the tips from our rewards pool.