Python pyenv and pythonpyenv

Source: Internet
Author: User
Tags virtualenv

Python pyenv and pythonpyenv

I. Introduction

We usually Install Multiple Python versions in the operating system, so it is troublesome to switch the Python version. pyenv provides a simple method, it is a simple and elegant tool that can easily switch between multiple Python versions. Pyenv has the following functions:

1) switch the global Python version 2) provide the corresponding Python version for a single project 3) use environment variables to allow you to rewrite Python version 4) search commands between different versions at the same time

Pyenv has the following features:

1) only depends on Python. 2) Add the directory to $ PATH. 3) perform virtualenv management.

 

Ii. Installation

The following two methods are described:

1) Method 1:

Step 1: Run

curl -L https://raw.githubusercontent.com/yyuu/pyenv-installer/master/bin/pyenv-installer | bash
Step 2: After running the preceding command, the following prompt appears in the command line.Add ~ /. Bashrc, source ~ /. Bashrc to make it take effect, so that our pyenv is initially installed successfully.

#Seems you still have not added 'pyenv' to the load path:export PYENV_ROOT="${HOME}/.pyenv"if [ -d "${PYENV_ROOT}" ]; then  export PATH="${PYENV_ROOT}/bin:${PATH}"  eval "$(pyenv init -)"fi

Step 3:In CentOS/RHEL/Fedora, when installing Python, you must first install other dependent software packages and execute the following script to solve the dependency problem:

http://files.cnblogs.com/files/274914765qq/pyenv_resolve_dependent.sh

2) Method 2:

Step 1: execute the following commands in sequence
wget http://files.cnblogs.com/files/274914765qq/pyenv-20150113.1.tar.gz
tar -zxvf pyenv-20150113.1.tar.gz
cd pyenv-20150113.1
python setup.py install

Step 2: After running the preceding command, the following prompt appears in the command line.Add ~ /. Bashrc, source ~ /. Bashrc to make it take effect, so that our pyenv is initially installed successfully.

# Load pyenv automatically by adding# the following to your profile:export PATH="$HOME/.pyenv/bin:$PATH"eval "$(pyenv init -)"eval "$(pyenv virtualenv-init -)"

Step 3:In CentOS/RHEL/Fedora, when installing Python, you must first install other dependent software packages and execute the following script to solve the dependency problem:

http://files.cnblogs.com/files/274914765qq/pyenv_resolve_dependent.sh

 

Iii. Use instances

1) display the currently used Python

pyenv versions

2) display the current Python security path

pyenv which python
3) set the default Python version
pyenv global

4) create a. python-version in the current path, and switch to this version automatically after entering this directory.

pyenv local

5) Enable a Python version in the Current shell session with a higher priority than global and local

pyenv shell

6) install the specified Python version

pyenv install -v 2.7.3

7) uninstall the specified Python version

pyenv uninstall -v 2.7.3

8) update the database after installation.

pyenv rehash

 

Reference: https://github.com/yyuu/pyenv-installer
     http://seisman.info/python-pyenv.html
     http://my.oschina.net/lionets/blog/267469

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.