Notes on installing Python using PyEnv

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.

Installing Python with PyEnv

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

It's like how to use

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.

Repository side

~/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

Installation side

~/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

Notes on installing Python using PyEnv
Notes on installing Python on Mac
Notes on installing Python on CentOS
Notes on installing Python3 and using pip on Windows7
Introducing Python using pyenv on Ubuntu 20.04
Notes on using MeCab from Python
Notes on using rstrip with python.
Install Python on CentOS using Pyenv
Install Python on CentOS using pyenv
(Beginner) Notes on using pyenv on Mac
Notes for using OpenCV on Windows10 Python 3.8.3.
Notes on building Python and pyenv on Mac
Notes on using code formatter in Python
Notes on installing PycURL
Installing pandas on python2.6
Installing pyenv on ubuntu 16.04
Notes using Python subprocesses
Notes on using Alembic
Install Python 3.8.6 on macOS Big Sur using pyenv
Notes on using dict in python [Competition Pro]
[Python] Notes on accelerating genetic algorithms using multiprocessing
Notes on setting pyenv and python environment using Homebrew on Mac OS Marvericks
Python notes using perl-ternary operator
Notes on installing dlib on mac
Python notes using perl-special variables
[Django] Notes on using django-debug-toolbar
Notes on pyenv and Atom
[Python] Notes on data analysis
Change python version using pyenv
Notes on optimization using Pytorch
Notes on installing pipenv on Mac
Broadcast on LINE using python
Notes on installing Anaconda 3 on Windows
Build a Python environment on your Mac using pyenv
Build a Python development environment using pyenv on MacOS
Minimum memo when using Python on Mac (pyenv edition)
Minimum notes when using Python on Mac (Homebrew edition)
Installing Kivy on Windows10 64bit Python3.5
pyenv notes
Preparing python using vscode on ubuntu
Support when installing pillow on python3.9
Installing Python 3.4.3.
Notes on using post-receive and post-merge
Installing Kivy-Designer on Windows10 64bit Python3.5
Study on Tokyo Rent Using Python (3-2)
Notes on accessing dashDB from python
Study on Tokyo Rent Using Python (3-3)
Notes on deploying pyenv with Homebrew and managing Python versions
Notes on using matplotlib on the server
Notes on installing Ubuntu 18.04 on the XPS 15 7590
List of libraries to install when installing Python using Pyenv
Until building a Python development environment using pyenv on Ubuntu 20.04
Notes using cChardet and python3-chardet in Python 3.3.1.
Execute Python code on C ++ (using Boost.Python)
Notes on PyQ machine learning python grammar
Detect "brightness" using python on Raspberry Pi 3!
Notes on nfc.ContactlessFrontend () for nfcpy in python
Notes for installing Sublime Text on Ubuntu
Put Anaconda on your Mac using Pyenv
Install python library on Lambda using [/ tmp]
Notes on doing Japanese OCR with Python