--Easily switch between multiple versions of Python. --Various versions of Python are placed under ~ / .pyenv.
$ curl -L https://raw.githubusercontent.com/pyenv/pyenv-installer/master/bin/pyenv-installer | bash
$ echo 'export PATH="$HOME/.pyenv/bin:$PATH"' >> ~/.bashrc
$ echo 'eval "$(pyenv init -)"' >> ~/.bashrc
$ echo 'eval "$(pyenv virtualenv-init -)"' >> ~/.bashrc
$ source ~/.bashrc
$ pyenv -v
pyenv 1.0.10-2-geef042a
--The command is described in detail here.
--If the installation fails, there are various notes in here.
--A list of python versions that can be installed with pyenv install --list
.
--If you do something like pyenv install 3.6.1
, 3.6.1 will be installed.
--pyenv versions
will show you the installed list and tell you which version is currently active.
$ pyenv install --list
$ apt-get install -y make build-essential libssl-dev zlib1g-dev libbz2-dev libreadline-dev libsqlite3-dev wget curl llvm libncurses5-dev libncursesw5-dev xz-utils
$ pyenv install 3.6.1
$ pyenv install anaconda3-4.3.1
$ pyenv versions
* system (set by /root/.pyenv/version)
3.6.1
anaconda3-4.3.1
$ python --version
Python 2.7.12
$ pyenv global 3.6.1
$ pyenv versions
system
* 3.6.1 (set by /root/.pyenv/version)
anaconda3-4.3.1
$ python --version
Python 3.6.1
--Can be used when you want to switch versions only in a specific directory.
--When pyenv local is executed, a file called .python-version
is created in the current directory where it was executed. This takes precedence over the global setting.
$ cd hoge
$ pyenv local anaconda3-4.3.1
$ python --version
Python 3.6.0 :: Anaconda 4.3.1 (64-bit)
$ cd ..
$ python --version
Python 3.6.1
By the way, when I looked at the contents of .python-version
, only the version name was written.
$ cat .python-version
anaconda3-4.3.1
$ pyenv which python3.6
/root/.pyenv/versions/3.6.1/bin/python3.6
By the way, I also try the ordinary which.
$ which python3.6
/root/.pyenv/shims/python3.6
$ which python
/root/.pyenv/shims/python
Recommended Posts