Categories

[Python] How to install Python on Linux

You are here:
  • Main
  • Linux
  • [Python] How to install Python on Linux
< All Topics

Hi guys! This time I’d want to explain how to install python3 in Linux for install your favourite packages, so you can make actions, for example connect to db or run script that you need.

ENVIRONMENT

  • Ubuntu 18.04 LTS
  • Python 2.7.17

How to install Python3

#You have to install python3

$ sudo apt update
$ sudo apt -y upgrade

#check version
$ python -v 

#Install pip for Pyhton, a tool which installs and
#manages libraries or modules in your project
$ sudo apt install -y python3-pip

#how to install package
$pip3 install package_name

#Install additional tools
$sudo apt install build-essential libssl-dev \
libffi-dev python3-dev

#install env
$sudo apt install -y python3-venv

#how to to create a virtual-enviroment
$python3.6 -m venv my_env

#Activate my enviroment
$source my_env/bin/Activate

#test virtual enviroment
(my_env) python

>>>print("Hello! Saruman!")

Deactive virtual enviroment
>>> quit
(my_env) $ deactivate

#how to run python cd /to/your/Path/
$python3 name_file.py

Table of Contents