How to Install the Python And Switch of Environment?
How to install the python and switch of environment?¶
Introduction
Sometimes, we need to different python versions development. The pyenv is very easier to help us switching any python versions.
Equipment
Operation System: Ubuntu 14.04 LTS
Usage
1.. If you haven't used GIT, you should install it before you get started.
$ sudo apt-get install curl git-core
2.. For automatically install pyenv.
$ curl https://raw.github.com/yyuu/pyenv-installer/master/bin/pyenv-installer | bash
3.. Open up .bashrc located in your home directory with a text editor and add the following.
File Name: .bashrc
# Python environment switch
export PYENV_ROOT="$HOME/.pyenv"
export PATH="$PYENV_ROOT/bin:$PATH"
eval "$(pyenv init -)"
(Save it)
$ source ~/.bashrc
4.. To Verify pyenv is installed properly
$ pyenv --version
pyenv 20140924-1-g737e0f1
5.. List of Python versions.
$ pyenv install –list
Available versions:
2.1.3
2.2.3
2.3.7
2.4
2.4.1
(… More)
6.. To install a python version.
$ pyenv install 3.3.4 -v
/tmp/python-build.20150111112656.5021 ~
Downloading Python-3.3.4.tgz...
HTTP/1.1 200 OK
Server: GitHub.com
Content-Type: application/octet-stream
Last-Modified: Tue, 04 Nov 2014 09:32:24 GMT
Expires: Sun, 11 Jan 2015 03:36:56 GMT
Cache-Control: max-age=600
Content-Length: 16843278
Accept-Ranges: bytes
Date: Sun, 11 Jan 2015 03:27:01 GMT
Via: 1.1 varnish
Age: 5
Connection: keep-alive
X-Served-By: cache-ty67-TYO
X-Cache: MISS
X-Cache-Hits: 0
X-Timer: S1420946816.328055,VS0,VE4793
Vary: Accept-Encoding
-> http://yyuu.github.io/pythons/ea055db9dd004a6ecd7690abc9734573763686dd768122316bae2dfd026412af
(… More)
7.. To list python versions.
$ pyenv versions * system (set by /home/brianlai/.python-version) 2.6.6 3.3.4
8.. To switch another python version.
$ export PYENV_VERSION=3.3.4 $ pyenv versions system 2.6.6 * 3.3.4 (set by PYENV_VERSION environment variable)
$ export PYENV_VERSION=system $ pyenv versions * system (set by PYENV_VERSION environment variable) 2.6.6 3.3.4
Exception
None
Reference
[1] http://davebehnke.com/python-pyenv-ubuntu.html
Acknowledge
Thank you (Pyenv) very much for this great development utility.