Instalar python 2.x

No CentOS só vem instalado o python 2.4 e não dá directamente para fazer o update para novas versões, para instalar a versão python 2.5 ou 2.6 pode fazer da seguinte forma:

Vamos instalar um novo repositório:

wget --directory-prefix=/etc/yum.repos.d/ http://mirrors.geekymedia.com/centos/geekymedia.repoCode language: Bash (bash)

De seguida já podemos instalar o python por yum da seguinte forma:

python 2.5

yum -y install python25Code language: Bash (bash)

python 2.6

yum -y install python26Code language: Bash (bash)

Depois vamos alterar o caminho para o python instalado para que quando executemos o comando python não vá executar o antigo python 2.4.

1) Vamos renomear o ficheiro de python.

mv /usr/bin/python /usr/bin/python.oldCode language: Bash (bash)

2) Vamos criar um link para o python desejado:

Python 2.5

ln -s /usr/bin/python25 pythonCode language: Bash (bash)

Python 2.6

ln -s /usr/bin/python26 pythonCode language: Bash (bash)

Para testarem basta executarem o comando python e ver qual a versão:

Python 2.5.1 (r251:54863, Sep 24 2008, 16:12:26)
[GCC 4.1.2 20070626 (Red Hat 4.1.2-14)] on linux2
Type "help", "copyright", "credits" or "license" for more information.
>>>

Follow SOS-Admins on Google

SOS-Admins is your ultimate source for the latest updates, exclusive guides, and news. Don t miss our upcoming content, add us to your favorites and stay connected with the community on Google!