Pyenv of Python Multi-version coexistence management tools

Source: Internet
Author: User
Tags install openssl rehash

1. Installing pyenv
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
2. Install Python

To view the installable version

install --list

This command lists the Python versions that can be installed with pyenv, with only a few examples:

2.7.8 # Python 2 Latest Version
3.4.1 # Python 3 Latest Version
anaconda-2.0.1 # supports Python 2.6 and 2.7
anaconda3-2.0.1 # supports Python 3.3 and 3.4
One of the shapes, such as x.x.x, is the official version of the Python version, and the other shapes, such as xxxxx-x.x.x, are either "derivative" or "release" after the same name and version.

2.1 Installing Python's dependency packages

When you install Python, you need to first install the other packages it relies on, and some known libraries that require pre-installation are as follows.

Under the Centos/rhel/fedora:

install readline readline-devel readline-staticsudo yum install openssl openssl-devel openssl-staticsudo yum install sqlite-develsudo yum install bzip2-devel bzip2-libs
2.2 Installing the specified version

Use the following command to install Python 3.4.1:

install 3.4.1 -v

The command downloads python's source code from GitHub, extracts it to the/tmp directory, and performs the compilation work in/tmp. If the dependent package is not installed, a compilation error occurs and the command needs to be re-executed after the dependent package is installed.

For the scientific research environment, it is recommended to install the Anaconda release which is specially prepared for scientific calculation, pyenv install anaconda-2.1.0 installs the 2.x version, pyenv install anaconda3-2.1.0 installs 3.x version;

Anacoda is very large, with pyenv download will be slow, you can go to the Anaconda official website to download, and the downloaded files in the ~/.pyenv/cache directory, then Pyenv will not be repeated download.

2.3 Updating the database

After the installation is complete, the database needs to be updated:

rehash

View the currently installed Python version

/home/seisman/.pyenv/version)3.4.1

The asterisk indicates that the python that is being used by the system is currently in use.

2.4 Setting the Global Python version
global 3.4.1$ pyenv versionssystem* 3.4.1 (set by /home/seisman/.pyenv/version)

The current global Python version has become 3.4.1. You can also use the pyenv local or pyenv shell to temporarily change the Python version.

2.5 Confirm Python Version
3.4.1 (default, Sep 10 2014, 17:10:18)[GCC 4.4.7 20120313 (Red Hat 4.4.7-1)] on linuxType "help", "copyright", "credits" or "license" for more information.>>>
3.0 using Python

Enter Python to use the new version of Python;
The system comes with a script that calls the old version of Python directly in a/usr/bin/python manner, and thus does not affect the system script;
Installing a third-party module with PIP is installed under ~/.pyenv/versions/3.4.1 and does not conflict with the system module.
After using PIP to install the module, you may need to perform pyenv rehash update the database;

Pyenv of Python Multi-version coexistence management tools

Related Article

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.