Use multiple versions of python environment with pyenv

Target

-[] Use pvenv while switching between multiple python version environments

Environmental preparation

Package upgrade + additional installation

$ sudo apt-get update
$ sudo apt-get upgrade
$ sudo apt-get install git gcc make openssl libssl-dev libbz2-dev libreadline-dev libsqlite3-dev

Install pyenv

$ cd /usr/local/
$ sudo git clone git://github.com/yyuu/pyenv.git ./pyenv
$ sudo mkdir -p ./pyenv/versions ./pyenv/shims
$ cd /usr/local/pyenv/plugins/

Install Pyenv-virtualenv

$ sudo git clone git://github.com/yyuu/pyenv-virtualenv.git
$ echo 'export PYENV_ROOT="/usr/local/pyenv"' | sudo tee -a /etc/profile.d/pyenv.sh
$ echo 'export PATH="${PYENV_ROOT}/shims:${PYENV_ROOT}/bin:${PATH}"' | sudo tee -a /etc/profile.d/pyenv.sh
$ source /etc/profile.d/pyenv.sh
$ pyenv --version

Change settings so that the environment can be inherited during sudo

sudo vi /etc/sudoers
    #Defaults    secure_path = /sbin:/bin:/usr/sbin:/usr/bin
    Defaults    env_keep += "PATH"
    Defaults    env_keep += "PYENV_ROOT"

Install Python (try installing 2.7.13 and 3.6.1)

$ pyenv install --list  ###Check the installable version
$ sudo pyenv install -v 2.7.13
$ sudo pyenv install -v 3.6.1

Change the default Python from the system default to 2.7.13

$ python --version
Python 2.7.6
$ pyenv versions
* system (set by /usr/local/pyenv/version)
  2.7.13
  3.6.1
$ sudo pyenv global 2.7.13
$ python --version
Python 2.7.13
$ pyenv versions
  system
* 2.7.13 (set by /usr/local/pyenv/version)
  3.6.1

Recommended Posts

Use multiple versions of python environment with pyenv
Use smbus with python3 under pyenv environment
python development environment -use of pyenv and virtualenv-
Install multiple versions of Python
The story of sharing the pyenv environment with multiple users
Use Python installed with pyenv for PL / Python execution environment
Use python installed with Pyenv with Sublime REPL of Sublime Text 3
Use Python in pyenv with NeoVim
[Pyenv] Building a python environment with ubuntu 16.04
[Ubuntu 18.04] Python environment construction with pyenv + pipenv
Build a python virtual environment with pyenv
Manage multiple Python versions with update-alternatives (Ubuntu)
I couldn't use tkinter with python installed by pyenv of anyenv
Build and test a CI environment for multiple versions of Python
Prepare the execution environment of Python3 with Docker
[Python] Use JSON with Python
Unification of Python environment
Building an Anaconda environment for Python with pyenv
Use mecab with Python3
Manage Python multiple version environment with Pythonz, virtualenv
Use DynamoDB with Python
When you want to use multiple versions of the same Python library (virtual environment using venv)
Developed and verified with multiple python versions with direnv
Use Python 3.8 with Anaconda
Poetry-virtualenv environment construction with python of centos-sclo-rh ~ Notes
Use python with docker
Python environment with docker-compose
How to use tkinter with python in pyenv
Use Python in Anaconda environment with VS Code
Install python with pyenv
Let's use different versions of SQLite3 from Python3!
Virtual environment with Python 3.6
I want to use Python in the environment of pyenv + pipenv on Windows 10
I installed Pygame with Python 3.5.1 in the environment of pyenv on OS X
How to build an environment for using multiple versions of Python on Mac
Recommendation of building a portable Python environment with conda
Use Trello API with python
Use Anaconda in pyenv environment
Install Python environment with Anaconda
Manage python environment with virtualenv
Use Twitter API with Python
Use TUN / TAP with Python
Build python3 environment with ubuntu 16.04
Prepare python3 environment with Docker
Build python environment with direnv
Reinstall python with pyenv with -fPIC
python with pyenv and venv
Use subsonic API with python3
Environment construction of python2 & 3 (OSX)
Using multiple versions of Python on Mac OS X (2) Usage
How to display a list of installable versions with pyenv
Get a clean Python development environment with pyenv + pipx + Poetry
Build a python environment with pyenv (OS X El Capitan 10.11.3)
Notes on deploying pyenv with Homebrew and managing Python versions
Build a Python environment with WSL + Pyenv + Jupyter + VS Code
[ev3dev × Python] Control of multiple motors
Python: How to use async with
Get started with Python! ~ ① Environment construction ~
Use PointGrey camera with Python (PyCapture2)
Build python virtual environment with virtualenv
Setup modern Python environment with Homebrew