How to install pyenv:
$ brew install pyenv
Add the following to .bashrc
export PYENV_ROOT=$HOME/.pyenv
export PATH=$PYENV_ROOT/bin:$PATH
eval "$(pyenv init -)"
eval "$(pyenv virtualenv-init -)"
Also have the Virtualenv plugin installed:
$ brew install pyenv-virtualenv
List of installable versions
$ pyenv install --list
Available versions:
2.1.3
2.2.3
2.3.7
2.4
...
You can install not only standard Python but also anaconda and pypy.
List of installed versions
$ pyenv versions
system
2.7.13
3.6.1
* anaconda2-4.3.1 (set by /Users/yassu/.pyenv/version)
* anaconda3-4.3.1 (set by /Users/yassu/.pyenv/version)
At first there should be only system and system should be checked.
pyenv install {version}
This {version}
is the version you can get with pyenv install --list
.
For example, the latest version of python is 3.6.1, so to install it
$ pyenv install 3.6.1
To change the version of a global, python command
$ pyenv global {version1} [version2]
If you do not specify version2
, the version is always fixed at` {version1}'.
If you specify version2
, the python
command uses {version1}
.
The python {n}
command uses the corresponding version.
For example, if you say pyenv global 3.6.1 2.7.13
, the python
command will version
3.6.1 is used, but version 2.7.13
can be used with the python2
command.
To specify the python version under any directory, go to that directory and then
$ pyenv local {version}
You can also use two versions as well as pyenv global
.
Temporarily specify the version:
$ pyenv shell {version}
$ pyenv local {base-version} {version}
So, copy {base-version}
and duplicate {version}
.
Recommended Posts