Hi, In this post i will show you how to install Python on Ubuntu22.04 and Set the Programming environment. I will also run a program and show the Output.
Hope you already aware about the Python.
Follow the below command to install Python.
Update local packages
$ sudo apt update
upgrade the packages of your machine
$ sudo apt -y upgrade
It might be prompt for your confirmation , Hit Y and press Enter.
$ python3 -V
As you all know python is already installed and give you a output like below
Python X.XX.X+
Now for the Programming we need to install PIP.
Let’s install the pip.
$ sudo apt install -y python3-pip
Install the packages which are required for pyothon
$ sudo apt install -y build-essential libssl-dev libffi-dev python3-dev
Install venv which is required for creating Programming environment.
$ sudo apt install -y python3-venv
$ mkdir environments
$ python3 -m venv my_env
Now activate the environment which we creating above.
$ source my_env/bin/activate
now you can create a python file and run. I am creating a “Hello Developers” Program.
(my_env) sudhir@ubuntu:~/environments$ nano hello.py
Note- “(my_env) sudhir@ubuntu:~/environments $” This is your path ,In your system Just type nano hello.py
Write
print(“Hello, Developers!”)
and press CTRL + X , Y then hit Enter.
(my_env) sudhir@ubuntu:~/environments$ python hello.py
You will see the output.
Hello, Developers!