Python is a popular programming language noted for its ease of use and adaptability. If you are an Ubuntu 22.04 user who wants to get started with Python, this article will walk you through the process of installing and configuring Python on your Ubuntu 22.04 system.
Step 1: Update System Packages
Before installing Python, make sure your system's package lists and repositories are up to current. Launch a terminal and type the following commands:
sudo apt update
sudo apt upgrade
Step 2: Check Python Version
Ubuntu 22.04 comes pre-installed with Python 3.x. To check the default Python version, open a terminal and run the following command:
python3 --version
Step 3: Install Python
If you discover that Python is not installed or you need a different version, Ubuntu provides a straightforward installation process. Open a terminal and enter the following command to install Python 3:
sudo apt install python3
Step 4: Verify Python Installation
After the installation is complete, verify that Python is installed correctly by running the following command in the terminal:
python3 --version
This command will display the Python version installed on your system.
Step 5: Install Pip
Pip is the standard package manager for Python, allowing you to easily install additional libraries and modules. To install Pip, use the following command:
sudo apt install python3-pip
Step 6: Verify Pip Installation
To confirm that Pip is installed correctly, run the following command:
pip3 --version
This command will display the Pip version installed on your system.
Step 7: Verify Pip Installation
Virtual environments are isolated Python environments that allow you to work on different projects with their own dependencies. To create a virtual environment, run the following command:
python3 -m venv myenv
Replace “myenv” with the desired name for your environement.
Step 8: Activate the Virtual Environment
To activate the virtual environment, use the following command:
source myenv/bin/activate
Step 9: Deactivate the Virtual Environment
To deactivate the virtual environment and return to your system’s default Python environment, execute the following command:
deactivate
Step 10: Install Python Packages
Once you have activated the virtual environment, you can install Python packages using Pip. For example, to install the popular Requests library, run the following command:
pip install requests
Bonus Step
While you can write Python code in any text editor, using an Integrated Development Environment (IDE) can greatly enhance your development experience. Some popular Python IDEs for Ubuntu include VS Code, PyCharm, Atom and Sublime Text. To install an IDE, please utilize the links provided below for each IDE and follow the instructions provided by the software's documentation.
Pycharm: https://www.jetbrains.com/pycharm/
Atom: https: https://atom.en.softonic.com/
Sublime Text: https://www.sublimetext.com/3
Conclusion
Congratulations! You have successfully installed and set up Python on your Ubuntu 22.04 system. This guide has walked you through the installation process, checking the Python version, installing Pip, creating and activating virtual environments, and installing Python packages. With Python up and running, you're now ready to explore the vast world of Python programming and develop exciting projects on your Ubuntu 22.04 system. Happy coding!
Top comments (0)