DEV Community

Shaikh Al Amin
Shaikh Al Amin

Posted on • Updated on

How to setup Python 3.10 or later, venv and pip setup in Ubuntu

To Install python 3.10 or latest:


sudo apt update 
sudo apt upgrade

Enter fullscreen mode Exit fullscreen mode

Install dependencies


sudo apt install -y software-properties-common build-essential libffi-dev libssl-dev zlib1g-dev libncurses5-dev libncursesw5-dev libreadline-dev libsqlite3-dev libgdbm-dev libdb5.3-dev libbz2-dev libexpat1-dev liblzma-dev libffi-dev libssl-dev 

Enter fullscreen mode Exit fullscreen mode

Add PPA dependencies:

sudo add-apt-repository ppa:deadsnakes/ppa 
Enter fullscreen mode Exit fullscreen mode

Update the system:

sudo apt update 
Enter fullscreen mode Exit fullscreen mode

Install python 3.10 and venv

sudo apt install -y python3.10 python3.10-venv
Enter fullscreen mode Exit fullscreen mode

To install pip

sudo apt install -y python3.10-pip

Enter fullscreen mode Exit fullscreen mode

To create a virtual env run the below command

python3.10 -m venv venv
Enter fullscreen mode Exit fullscreen mode

To activate virtual env run the below command

source venv/bin/activate
Enter fullscreen mode Exit fullscreen mode

To deactivate just type deactivate

deactivate
Enter fullscreen mode Exit fullscreen mode

Deleting the Python Virtual Environment

rm -rf venv 
Enter fullscreen mode Exit fullscreen mode

To check the installed Python package inside the virtual env run the below command

pip list or pip3 list
Enter fullscreen mode Exit fullscreen mode

Top comments (0)