PYENV installation and use-multi-version Python coexistence solution

Source: Internet
Author: User
Tags install openssl

Description

Python is generally low due to CentOS or Rhel OS, CENTOS6 The Python version is 2.6.6, but now the general Python version is 2.7 version, previously always in the operation of the source code upgrade Python, but this will lead to the use of Python and other uses of the command error, although modified Yum source code can solve the problem, but always feel very troublesome, and a life Make the file changes also feel very low Ah!


Found pyenv This software is very good, can coexist in a system of two Python versions, and does not affect the system comes with the old version of Python use;


Install pyenv first install the RPM package environment required for Python compilation:

Yum Install ReadLine Readline-devel readline-static-y

Yum Install OpenSSL openssl-devel openssl-static-y

Yum Install Sqlite-devel-y

Yum Install Bzip2-devel bzip2-libs-y


Don't say much nonsense and start installing pyenv

git clone git://github.com/yyuu/pyenv.git ~/.pyenv

echo ' Export pyenv_root= ' $HOME/.pyenv ' >> ~/.BASHRC

echo ' Export path= ' $PYENV _root/bin: $PATH "' >> ~/.BASHRC

Echo ' eval ' $ (pyenv init-) "' >> ~/.BASHRC

EXEC $SHELL-L


To view the Python versions supported by pyenv:

650) this.width=650; "src=" Http://s3.51cto.com/wyfs02/M00/6C/62/wKioL1VIc2nzf0msAAEGW5NqQdI070.jpg "title=" 360 Feedback 16330107315449.jpg "alt=" Wkiol1vic2nzf0msaaegw5nqqdi070.jpg "/>


Now to install Python 2.7.9 in the system,

Pyenv Install 2.7.9-v


To refresh the database:

Pyenv Rehash


There are now two different versions of Python in the system, but the system defaults to Python version 2.6 and is now switched:

Pyenv Global 2.7.9


650) this.width=650; "src=" Http://s3.51cto.com/wyfs02/M02/6C/66/wKiom1VIc5ehfdrYAACZfpvZGIw825.jpg "title=" 360 Feedback 16760923465396.jpg "alt=" Wkiom1vic5ehfdryaaczfpvzgiw825.jpg "/>



Now the system default Python version is 2.7.9, yum can be used normally, because Yum annotation is "/usr/bin/python", we write our own python with "/usr/bin/env python", This is for the system environment in Python 2.7.9!


Pyenv good, very convenient, will not cause the Python version of the system confusion problem!


This article is from the "Shine_forever blog" blog, make sure to keep this source http://shineforever.blog.51cto.com/1429204/1642113

PYENV installation and use-multi-version Python coexistence solution

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.