I use phpenv a lot for my work, but I haven't used PyEnv so much, so I'll use it for testing.
Since it is a command created as a Python version of rbenv, the command options etc. are the same.
It seems that it has been around for quite some time, so as an alternative to the Memo with Python2.7 and Python3.3 in CentOS I wrote earlier.
$ git clone https://github.com/yyuu/pyenv.git ~/.pyenv
After execution, write the following in .zshenv
or .bash_profile
. (Don't write in .bashrc
. It looks like you're stuck in an infinite loop Github issue # 264. I'm only looking at README.md I'm not chasing you.)
.zshenv
if [ -e "$HOME/.pyenv" ]; then
export PYENV_ROOT="$HOME/.pyenv"
export PATH="$PYENV_ROOT/bin:$PATH"
eval "$(pyenv init -)"
fi
After writing, read the configuration file
$ source .bash_profile
$ source .zshenv
This completes the installation of PyEnv.
By the way, the MacOSX
version is brew install pyenv
in HomeBrew.
Try installing pypy3-2.4.0
and 3.5.0
.
$ pyenv install 3.5.0
Downloading Python-3.5.0.tgz...
-> https://yyuu.github.io/pythons/584e3d5a02692ca52fce505e68ecd77248a6f2c99adf9db144a39087336b0fe0
Installing Python-3.5.0...
Installed Python-3.5.0 to /home/yasui/.pyenv/versions/3.5.0
$ pyenv install pypy3-2.4.0
Downloading pypy3-2.4-linux_x86_64-portable.tar.bz2...
-> https://bitbucket.org/squeaky/portable-pypy/downloads/pypy3-2.4-linux_x86_64-portable.tar.bz2
Installing pypy3-2.4-linux_x86_64-portable...
Installing pip from https://bootstrap.pypa.io/get-pip.py...
Installed pypy3-2.4-linux_x86_64-portable to /home/yasui/.pyenv/versions/pypy3-2.4.0
$ pyenv versions
* system (set by /home/yasui/.pyenv/version)
3.5.0
pypy3-2.4.0
$ python --version
Python 2.6.6
$ which python
~/.pyenv/shims/python
It looks like it's installed, so I'll try using 3.5.0
as the main.
$ pyenv global 3.5.0
~ $ python --version
Python 3.5.0
~ $ which python
~/.pyenv/shims/python
For a specific project, if it depends on the Python version, put the .python-version
created by pyenv local
in the Git repository, deploy it on the server side, or for other developers. When you install it, run pyenv install
on that repository to get the version of Python for that project.
~/test1 $ pyenv global
3.5.0
~/test1 $ ls git:master ?
./ ../ .git/
~/test1 $ pyenv local 2.7.10
~/test1 $ ls
./ ../ .git/ .python-version
$ git commit -a -m 'add .python-version' git:master
[master (root-commit) b40425f] add .python-version
1 files changed, 1 insertions(+), 0 deletions(-)
create mode 100644 .python-version
~/test $ cat .python-version
2.7.10
~/test $ pyenv versions
pyenv: version `2.7.10' is not installed
system
3.5.0
pypy3-2.4.0
~/test $ pyenv install
Downloading Python-2.7.10.tgz...
-> https://yyuu.github.io/pythons/eda8ce6eec03e74991abb5384170e7c65fcd7522e409b8e83d7e6372add0f12a
Installing Python-2.7.10...
patching file ./Lib/site.py
Installed Python-2.7.10 to /home/yasui/.pyenv/versions/2.7.10
~/test $ python --version
Python 2.7.10
After that, every time you move to that project, the pyenv shell will automatically make a good version for you.
~ $ python --version
Python 3.5.0
~ $ cd test
~/test $ python --version
Python 2.7.10
Recommended Posts