Python is a versatile and widely-used programming language known for its readability and object-oriented approach. In this article, we will guide you through the process of installing Python 3.10 on AlmaLinux 9, a powerful and secure Linux distribution. By following these steps, you will be able to leverage the latest features and enhancements offered by Python for your development projects.
Prerequisites
Before we begin, ensure that you have the following prerequisites in place:
- A system with AlmaLinux 9 installed and running.
- Root access to the system.
Additionally, you will need to install some additional packages and dependencies to successfully install Python from the source code. Run the following command to install them:
dnf install wget yum-utils make gcc openssl-devel bzip2-devel libffi-devel zlib-devel
Installing Python 3.10.5
At the time of writing this article, the latest version of Python available is 3.10.5. To install Python, follow these steps:
- Visit the official Python website at https://www.python.org/downloads/ to check for the latest version available.
- Use the
wget
command to download the source code of Python 3.10.5. Run the following command:
wget https://www.python.org/ftp/python/3.10.5/Python-3.10.5.tgz
- Extract the downloaded file using the
tar
command:
tar xzf Python-3.10.5.tgz
- Change the directory to the extracted Python source code:
cd Python-3.10.5
- Configure the source code with the required values using the following command:
./configure --with-system-ffi --with-computed-gotos --enable-loadable-sqlite-extensions
- Compile the source code using the
make
command. Thenproc
command will provide the number of CPU cores available, allowing for faster compilation. Run the following command:
make -j $(nproc) make altinstall
Once the installation is complete, you can verify the Python version using the following command:
python3.10-V
Creating a Virtual Environment
It is best practice to work within a virtual environment to isolate your Python projects and their dependencies. To create a virtual environment for your Python 3.10.5 installation, follow these steps:
- Activate the root user or use the
sudo
command to run the following command:
/usr/local/bin/python3.10-m venv appenv
- Activate the virtual environment using the following command:
source appenv/bin/activate
You will notice that the prompt changes to indicate that you are now working within the virtual environment.
Verifying the Installation
To verify that Python 3.10.5 is successfully installed within the virtual environment, you can run the following command:
python -V
This command should display the installed Python version.
To exit the virtual environment and return to the root user, run the following command:
deactivate
Congratulations! You have successfully installed Python 3.10.5 on AlmaLinux 9 and created a virtual environment to work with. You are now ready to take advantage of the latest features and improvements offered by Python for your development projects.
For reliable and scalable cloud hosting solutions, consider Shape.host’s Linux SSD VPS services. Shape.host provides efficient and secure hosting solutions, empowering businesses with reliable infrastructure. Visit Shape.host for more information.