
Python is a modern high-level programming language for developing web applications, running artificial intelligence (AI) models, and performing data analysis. Pip, a standard package manager for Python, allows you to install and manage libraries or dependencies in your Python project.
This article explains how to install Pip on FreeBSD 14. You will also install multiple Python versions and create an isolated development environment using the venv module.
Before you begin:
The FreeBSD operating system preinstalls Python by default, and you can also pull it from the package repositories using the pkg package manager. However, those Python versions might be out of date. Follow the steps below to verify the default Python version and install the latest Python version on your server by building the application from source.
View the default Python version.
Output:
Download the latest Python version release file. For example, version 3.13. Visit the Python releases page to verify the latest version.
Extract all files from the archive.
Switch to the new Python directory. For example, Python-3.13.0.
Run the configure script to initialize the build process.
Use make to build Python from source.
Install Python. The altinstall option installs the Python version without overwriting the default version.
View the new Python version.
Output:
Verify that the default version is available and unchanged.
Output:
You have installed the latest Python version on your FreeBSD server.
Run the following command to remove the pre-installed version.
Allow the python3 command to use the new version by default.
Pip is the standard Python package manager for installing and managing project dependencies. Depending on the running Python version, follow the steps below to verify and install Pip on FreeBSD 14 server.
View the default Pip version on your server.
Verify that the command fails with the following output:
Download the latest Pip installation script.
Install a Pip version based on your Python version, such as the Python 3.13 you installed earlier.
Output:
Install Pip using the default Python version on your server.
View the new Pip version.
Output:
Find out how to install pip on ubuntu to manage Python packages effectively in your development environment.
Follow the steps below to test the Python package on FreeBSD.
Access the Python shell.
Run the following command to display a Hello World, Greetings from Vultr! message in your terminal.
Output:
Exit the Python shell.
Install a new Python module, such as flask using Pip.
Output:
Multiple projects may require different Python versions on your server. You can install new Python versions using the pkg package manager or use a project management tool such as pyenv to install and manage multiple Python versions.
Update the server's package information index.
Install the git dependency package.
Install the pyenv tool.
View the available Python versions you can install on your server.
Output:
Install a specific Python version such as 3.14-dev.
Install another version, such as 3.12.6.
View all installed Python versions in your environment.
Output:
Set a specific Python version as the default in your environment. For instance, 3.12.6.
View the active Python version in your environment.
Output:
Python uses the venv module to create isolated virtual environments on your server, allowing you to separate specific dependencies in your project from the system-wide Python environment. Follow the steps below to create a new virtual environment using the venv module.
Create a new myenv virtual environment.
Activate the myenv virtual environment.
Verify that your terminal prompt changes and includes the name of the new environment similar to the output below.
View the active python binary path.
Verify that the Python binary is active in your virtual environment path similar to the output below.
Install a Python package such as requests using Pip in the new environment.
Output:
List all available Python modules in the environment.
Output:
Exit the virtual environment.
You have installed Pip on FreeBSD 14 along with Python. Additionally, you've installed multiple Python versions to use with different projects and packages on the server. Python supports various tools that can be integrated with other applications, such as database servers, to match your project needs. For further details, please visit the Python documentation.
0 Comments
Be the first to comment and share your perspective with the community.