Python version switching (pyenv)

Overview

This is an article about changing the version of python. Some tools such as GCP tools (2.7 series) have a python version specified, so you will need to switch when using them. This time, how to switch versions using a tool called pyenv I will introduce the method by anaconda.

Procedure (pyenv edition)

//Install pyenv
$ brew install pyenv

//Reference of installable version
$ pyenv install -l

//Install the version you want
$ pyenv install 2.7.16

//Check the version at hand
$ pyenv versions

//Version change: local for local, global for global
$ pyenv local 2.7.16
$ pyenv global 2.7.16

If the version does not change, check below If you are using anaconda for version control, proceed to the next step.

Procedure (anaconda edition)

If you already have anaconda etc. installed The version is not changed in pyenv because the reference destination is different. The conda environment is displayed at the beginning of the prompt

//Creating anaconda environment
conda create -n py27 python=2.7 anaconda

//Environmental confirmation at hand of anaconda
conda info -e

//Set the environment to use
conda activate py27

//Exit the conda environment(Return to base)
conda deactivate

Summary

The usability is similar, You will create and use a version and environment at hand.

Citation / Reference

In creating this article, I referred to the following article.

Use different python versions in Anaconda https://qiita.com/hurts14/items/116ef0e332e159a51c4f

Recommended Posts

Python version switching (pyenv)
Change python version using pyenv
pyenv + anaconda + python3
PYTHON2.7 64bit version
Install python (pyenv, pyenv-virtualenv)
Install python with pyenv
Check version with python
Causes when python version cannot be changed using pyenv
python (pyenv + pyenv-virtualenv) + CentOS7 installation
How is pyenv switching versions?
Breadth-first search / bidirectional search (Python version)
Petit stray Python version output
Version upgrade of python Anaconda
Python version does not switch
Reinstall python with pyenv with -fPIC
Check OpenSSL version of python 2.6
Markov switching model by Python
Introduction to Python (Python version APG4b)
How to change Python version
python with pyenv and venv
Specify python version with virtualenv
[Python] Anaconda, pyenv, virtualenv, .bash_profile
tesseract-OCR for Python [Japanese version]
Error resolution python version check
[Python] Tuple version of prefecture pull-down
Virtual Environment Version Control Summary Python
Raise the version of pyenv itself
Python
Anaconda and Python version correspondence table
Introducing Python using pyenv on Ubuntu 20.04
Install xgboost (python version) on Windows
Set python compile options with pyenv
pyenv-change the python version of virtualenv
Self-organizing map in Python NumPy version
How to get the Python version
Python environment construction (pyenv, anaconda, tensorflow)
[Code] Module and Python version output
Change the Python version of Homebrew
Master linear search! ~ Python implementation version ~
Python environment construction (pyenv + poetry + pipx)
Notes on installing Python using PyEnv
Unable to install Python with pyenv
Use Python in pyenv with NeoVim
[2021 version] Python installation Windows 10 (64bit) edition
Manage each Python version with Homebrew
Install Python on CentOS using Pyenv
Faster Fibonacci sequence calculations (Python version)
Change the active version in Pyenv from anaconda to plain Python
Python version to get unused ports
Install Python on CentOS using pyenv
[AWS SAM] Introduction to Python version
[Python Windows] pip install with Python version
Python virtual environment construction (2017 version) pyenv and pyenv-virtualenv and virtualenv and virtualenv wrapper and pyvenv and venv
[Ubuntu 18.04] Python environment construction with pyenv + pipenv
Install Python as a Framework with pyenv
Use smbus with python3 under pyenv environment
Python hand play (descriptor calculation: serious version)
About the virtual environment of python version 3.7
[Python] Try pydash of the Python version of lodash
Notes on building Python and pyenv on Mac
How to check opencv version in python