Build a python virtual environment with pyenv

When I set macOS to Sierra, Python's virtualenv doesn't work well, so I decided to rebuild the virtual environment with pyenv. The procedure at that time is summarized. It's easy, so you only need to remember the basic commands! It's easy to install, so even elementary school students can do it without any problems! !!

environment

Installation

Install pyenv

$ brew install pyenv

Python installation

Find out which version you can install

There are many versions coming out, so please install the version you like

$ pyenv install -l
Available versions:
  2.1.3
  2.2.3
  2.3.7
  2.4
  2.4.1
  2.4.2
  2.4.3
  2.4.4
  2.4.5
  2.4.6
  2.5
  2.5.1
  2.5.2
...

When installing Python 3.5.2.

$ pyenv install 3.5.2

Install pyenv virtualenv

$ brew install pyenv-virtualenv

Setting python version with pyenv

If you want the whole python version to be 3.5.2.

$ pyenv global 3.5.2

When reflecting only a specific directory If you type the command pyenv local XXX in a specific directory, the python version will be applied only to that directory.

$ cd PROJECT_DIR
$ pyenv local 2.7.10

Building a virtual environment with pyenv-virtualenv

Since it is difficult to change the environment with pyenv, I think it is basically more convenient to build a virtual environment with pyenv-virtualenv.

Create a virtual environment with pyenv-virtualenv

When creating a virtual environment with Python 3.5.2.

$ pyenv virtualenv 3.5.2 test

Enter the virtual environment with pyenv

$ pyenv activate XXXXX

Exit the virtual environment with pyenv

$ pyenv deactivate

Delete the virtual environment

For NAME, enter the name of the virtual environment you created.

$ pyenv uninstall NAME
pyenv-virtualenv: remove /Users/xxxx/.pyenv/versions/3.5.2/envs/test2? [Enter y]

Recommended Posts

Build a python virtual environment with pyenv
[Memo] Build a virtual environment with Pyenv + anaconda
Build a simple Python virtual environment without pyenv
Build a virtual environment with pyenv and venv
Build python virtual environment with virtualenv
Create a virtual environment with Python!
Building a virtual environment with Python 3
Build a python virtual environment with virtualenv and virtualenvwrapper
Build a python virtual environment with virtualenv and virtualenvwrapper
Virtual environment with Python 3.6
[Pyenv] Building a python environment with ubuntu 16.04
[Python] Create a virtual environment with Anaconda
Build a modern Python environment with Neovim
Build a python environment with pyenv (OS X El Capitan 10.11.3)
Build a Python environment with WSL + Pyenv + Jupyter + VS Code
Build python environment with pyenv on EC2 (ubuntu)
Build a python environment with ansible on centos6
[Python] Build a Django development environment with Docker
Create a python3 build environment with Sublime Text3
Build python3 environment with ubuntu 16.04
Build python environment with direnv
Work in a virtual environment with Python virtualenv.
Build a Python environment with OSX El capitan
Quickly build a Python Django environment with IntelliJ
Building a Python virtual environment
Build a Python machine learning environment with a container
Build a python execution environment with VS Code
Build a Python virtual environment that anyone can understand September 2016 (pyenv + virutalenv)
Create a virtual environment with Anaconda installed via Pyenv
Build a python environment for each directory with pyenv-virtualenv
Build a Python virtual environment using venv (Django + MySQL ①)
Build a Python environment on your Mac using pyenv
Build a machine learning application development environment with Python
Build a Python development environment using pyenv on MacOS
Build a Django environment for Win10 (with virtual space)
Build a numerical calculation environment with pyenv and miniconda3
Build Mysql + Python environment with docker
Build a python3 environment on CentOS7
How to build a new python virtual environment on Ubuntu
Get a clean Python development environment with pyenv + pipx + Poetry
How to build a python2.7 series development environment with Vagrant
[Ubuntu 18.04] Python environment construction with pyenv + pipenv
Building a Python3 environment with Amazon Linux2
Easily build a development environment with Laragon
Build Jupyter Lab (Python) environment with Docker
Install Python as a Framework with pyenv
Use smbus with python3 under pyenv environment
Build a blockchain with Python ① Create a class
Build a python environment on MacOS (Catallina)
Build a Tensorflow environment with Raspberry Pi [2020]
Let's create a virtual environment for Python
Building a Python 3.6 environment with Windows + PowerShell
I want to build a Python environment
Build a Fast API environment with docker-compose
[Mac] Building a virtual environment for Python
Creating a python virtual environment on Windows
Create a virtual environment with Python_Mac version
Build Python environment with Anaconda on Mac
[Linux] Build a jenkins environment with Docker
Build a Python + OpenCV environment on Cloud9
Add a Python virtual environment to VSCode