Create a Python (pyenv / virtualenv) development environment on Mac (Homebrew)

Introduction

For those of you who don't want to pollute Python already installed on your mac when creating a Python development environment, this article describes how to achieve the following goals:

--Switch Python version and environment (installed pip module) for each directory --Code management of pip module

Caution

――This article uses Homebrew for the very first installation to make it as easy as possible. Please install Homebrew in advance. ――Maybe there is a cooler way. ――It is troublesome to write the confirmation method, so please check it yourself.

Install pyenv`` pyenv-virtualenv with Homebrew

brew install pyenv pyenv-virtualenv
echo 'export PYENV_ROOT="${HOME}/.pyenv"' >> ~/.bash_profile
echo 'export PATH="${PYENV_ROOT}/bin:$PATH"' >> ~/.bash_profile
echo 'eval "$(pyenv init -)"' >> ~/.bash_profile
echo 'eval "$(pyenv virtualenv-init -)"' >> ~/.bash_profile
source ~/.bash_profile

Install Python with pyenv

pyenv install 3.5.0

Create a Python virtual environment installed with virtualenv

pyenv virtualenv 3.5.0 hoge_env

Create a home directory for development and associate that directory with the virtual environment

mkdir dev_home
cd dev_home
pyenv local hoge_env

Install pip-tools to manage the pip module

pip install pip-tools

Describe the pip module you want to install

mkdir requirements
vim requirements/bash.in

requirements/bash.in


mysqlclient
simple-db-migrate

See http://qiita.com/ryu22e/items/ad3f8f3df30886d23661 for how to write requirements / *. in

Install the module described in requirements /*.in

pip-compile requirements/base.in
pip-sync requirements/*.txt

Recommended Posts

Create a Python (pyenv / virtualenv) development environment on Mac (Homebrew)
Create a Python environment on Mac (2017/4)
Create a python environment on your Mac
Build a Python development environment on your Mac
Create a Python virtual development environment on Windows
Create a Python3 environment with pyenv on Mac and display a NetworkX graph
Create a comfortable Python 3 (Anaconda) development environment on windows
Build a Python development environment on Mac OS X
Build a Python environment on your Mac using pyenv
Build a Python development environment using pyenv on MacOS
Create a Python development environment on OS X Lion
Building a Python environment on Mac
Create a python environment on centos
Python environment construction on Mac (pyenv, virtualenv, anaconda, ipython notebook)
Create a virtual environment for python on mac [Very easy]
Until building a Python development environment using pyenv on Ubuntu 20.04
Pyenv + virtualenv on Mac
Create a Python environment
Python3 TensorFlow environment construction (Mac and pyenv virtualenv)
Build a Python environment on Mac (Mountain Lion)
python development environment -use of pyenv and virtualenv-
[Venv] Create a python virtual environment on Ubuntu
Set up a Python development environment on Marvericks
Create a Python execution environment on IBM i
[Note] How to create a Mac development environment
Build a Python development environment on Raspberry Pi
Create a Python development environment on Windows (Visual Studio Code remote WSL).
Notes on setting pyenv and python environment using Homebrew on Mac OS Marvericks
Build a GVim-based Python development environment on Windows 10 (3) GVim8.0 & Python3.6
Build a Django development environment using pyenv-virtualenv on Mac
Build a local development environment for Laravel6.X on Mac
Build a machine learning Python environment on Mac OS
Notes on creating a python development environment on macOS Catalina
Create a python development environment with vagrant + ansible + fabric
Build a GVim-based Python development environment on Windows 10 (1) Installation
Create a decent shell and python environment on Windows
Install Python environment on local PC (pyenv, venv on Mac)
Create a Python development environment in 10 minutes (Mac OS X + Visual Studio Code)
I want to create a nice Python development environment for my new Mac
Build a machine learning environment on mac (pyenv, deeplearning, opencv)
Prepare Python development environment on Ubuntu
Building a Python environment on Ubuntu
Building a Python environment on a Mac and using Jupyter lab
Create a VS Code + Docker development environment on a Linux VM
Create a virtual environment with Python!
Python environment construction memo on Mac
Create a GO development environment with [Mac OS Big Sur]
Create a Linux environment on Windows 10
Python development environment construction on macOS
Build a python data analysis environment on Mac (El Capitan)
How to create a Python 3.6.0 environment by putting pyenv on Amazon Linux and Ubuntu
Build a GVim-based Python development environment on Windows 10 (2) Basic settings
Environment construction of python3.8 on mac
Get a clean Python development environment with pyenv + pipx + Poetry
Create a simple Python development environment with VSCode & Docker Desktop
Install Python development environment on Windows 10
Build a python3 environment on CentOS7
I want to set up a GUI development environment with Python or Golang on Mac
Create a Python environment for professionals in VS Code on Windows
How to rebuild python environment from pyenv on Mac environment (El Capitan)
Build a Python environment on your Mac with Anaconda and PyCharm