GNU/Linux >> Linux Esercitazione >  >> Ubuntu

Come installare Python 2.7.18 su Ubuntu e LinuxMint

Questo articolo ti aiuterà a installare Python 2.7.18 sui tuoi sistemi operativi Ubuntu, Debian e LinuxMint. Al momento della stesura di questo articolo è disponibile per il download e l'installazione l'ultima versione stabile di Python 3.4.5.

Per installare Python 3.4.5, visita il seguente articolo.

  • Come installare Python 3.4 su Ubuntu e LinuxMint
  • Fase 1 – Prerequisiti

    È necessario aver installato i seguenti prerequisiti sul sistema. Esegui i seguenti comandi sul tuo sistema per installare tutte le dipendenze necessarie per compilare Python 2.7.

    sudo apt-get update
    sudo apt-get install build-essential checkinstall
    sudo apt-get install libreadline-gplv2-dev libncursesw5-dev libssl-dev libsqlite3-dev tk-dev libgdbm-dev libc6-dev libbz2-dev
    

    Fase 2:scarica Python 2.7

    Scarica Python usando il seguente comando dal sito ufficiale di Python. Puoi anche scaricare l'ultima versione al posto di quanto specificato di seguito.

    cd /usr/src
    wget https://www.python.org/ftp/python/2.7.18/Python-2.7.18.tgz
    

    Ora estrai il pacchetto scaricato.

    sudo tar xzf Python-2.7.18.tgz
    

    Fase 3 – Compila il sorgente Python

    Usa il seguente set di comandi per compilare il codice sorgente Python sul tuo sistema usando altinstall .

    cd Python-2.7.18
    sudo ./configure --enable-optimizations
    sudo make altinstall
    

    make altinstall viene utilizzato per impedire la sostituzione del file binario python predefinito /usr/bin/python.

    Passaggio 4:verifica della versione di Python

    Controlla l'ultima versione installata di Python usando il comando seguente

    python2.7 -V
    
    Python 2.7.18
    

    Ubuntu
    1. Come installare Python 3.7 su Ubuntu, Debian e LinuxMint

    2. Come installare Python 3.5 su Ubuntu, Debian e Linuxmint

    3. Come installare Python 3.6 su Ubuntu e LinuxMint

    4. Come installare Python 3.2 in Ubuntu 13.04?

    5. Come installare Python 3.9 su Ubuntu 20.04

    Come installare Python 3.9 su Ubuntu 20.04

    Come installare Python 3.11 su Ubuntu 20.04

    Come installare Python 3.6 su Ubuntu 16.04, Ubuntu 16.10, 17.04

    Come installare Python su Ubuntu 20.04

    Come installare Python su 3.9 Ubuntu 20.04

    Come installare Python su Ubuntu 22.04