Skip to main content

Installing Python on Manjaro Linux

Welcome to the world of Python programming on Manjaro Linux! Python is a versatile and powerful programming language that's widely used for web development, data analysis, artificial intelligence, scientific computing, and more. Manjaro, being an Arch Linux-based distribution, is known for its simplicity and user-friendliness, making it an excellent platform for Python development.

In this tutorial, we'll walk through the process of installing Python on Manjaro Linux. We'll cover the basics, the installation process, and some tips and tricks to ensure a smooth development experience. Whether you're a beginner or an experienced developer, this guide will help you set up Python on your Manjaro system.

Prerequisites

Before we begin, ensure that you have the following:.

  • A Manjaro Linux system up and running.
  • Access to the terminal (you can find it in your applications menu or by pressing Ctrl+Alt+T).
  • Basic knowledge of using the terminal and command-line interface.

Step 1: Checking for Existing Python Installations

Manjaro typically comes with Python pre-installed. To check if Python is already installed and its version, open the terminal and type:.

python --version
python3 --version

You should see output similar to:.

Python 3.9.1
Python 3.9.1

The output indicates which version(s) of Python are installed. Manjaro usually defaults to Python 3, as Python 2 has reached its end of life and is no longer maintained.

Step 2: Updating the System

It's always a good idea to update your system's package database before installing new software. Run the following commands to update your system:.

sudo pacman -Syu

This command synchronizes the repository databases and updates the system's packages. You may be prompted to confirm the updates. Press Enter to proceed or Ctrl+C to cancel.

Step 3: Installing Python

If Python is not installed or you need a different version, you can install it using Manjaro's package manager, pacman.

sudo pacman -S python python-pip

This command installs Python along with pip, which is Python's package installer. You'll use pip to install Python packages from the Python Package Index (PyPI).

Step 4: Using Python Virtual Environments

Virtual environments are a best practice in Python development, allowing you to manage dependencies for different projects separately. To create a virtual environment, you'll need the python-virtualenv package:.

sudo pacman -S python-virtualenv

Once installed, you can create a virtual environment for your project:.

python -m venv myprojectenv

Replace myprojectenv with the name you want for your virtual environment. To activate the virtual environment, run:.

source myprojectenv/bin/activate

Your terminal prompt should now indicate that you are working within the virtual environment (e.g., (myprojectenv) $). To deactivate the virtual environment, simply run:.

deactivate

Step 5: Verifying the Installation

To verify that Python has been installed correctly, run:.

python --version

You should see the version of Python that you installed. You can also start the Python interpreter by typing:.

python

You'll be greeted with the Python prompt, indicated by >>>. Here, you can execute Python code directly. For example, try:.

print("Hello, Manjaro!")

You should see the output:.

Hello, Manjaro!

Press Ctrl+D to exit the Python interpreter.

Step 6: Installing Additional Python Packages

With Python and pip installed, you can now install additional Python packages. For example, to install the popular requests library for making HTTP requests, run:.

pip install requests

Always ensure that you are installing packages within your virtual environment if you're working on a project that requires specific package versions.

Step 7: Keeping Python Updated

Manjaro's rolling release model means that Python will be updated along with the rest of your system. To update Python to the latest version, simply run the system update command:.

sudo pacman -Syu

Troubleshooting Common Issues

  • Permission Issues: If you encounter permission issues while installing Python packages, ensure that you are using the --user flag with pip to install packages for the current user:.
pip install --user package_name


  • Path Conflicts: If you have multiple versions of Python installed, there might be conflicts. Use python --version and python3 --version to check which version is being used by default. You can use python2 or python3 to specify the version you want to use.

  • SSL Certificate Errors: If you encounter SSL certificate errors when using pip, you may need to update your certificate store:.

sudo pacman -S ca-certificates-utils
sudo update-ca-trust

You now have Python installed on your Manjaro Linux system, and you're ready to start developing Python applications. Remember to use virtual environments for your projects to avoid dependency conflicts.

For further reading and resources, check out the Python documentation and the Manjaro Wiki. If you encounter any issues or have questions, the Manjaro forums and Arch Linux forums are great places to seek help.