Anyone can understand how to build an initial environment for Python on Mac September 2016 (pyenv + virutalenv)

Purpose of using Python

I started Python because I wanted to easily analyze the data of the products I run. I was wondering whether to choose R or Python, but I chose Python for the following three reasons.

What to install

The environment is Mac OSX 10.10.5, and it is assumed that Xcode and homebrew are installed.

Installation procedure

Install pyenv

What is pyenv?

A tool that allows you to easily switch between Python versions. You can install multiple versions of Python and specify the version to use for each directory. There are 2 series and 3x series in Python. Version control tools are useful because they are not syntactically compatible, so you can't read code 2 in series 3 and vice versa.

Installation procedure of pyenv

Install pyenv from homebrew.

$ brew install pyenv

Set environment variables for your shell (if you're using bash).

$ echo 'export PATH="$HOME/.pyenv/bin:$PATH"' >> ~/.bash_profile
$ echo 'eval "$(pyenv init -)"' >> ~/.bash_profile

Confirm that the installation is complete.

$ pyenv version

Install Python (2.7.12, 3.5.2)

Python is installed by default on Mac, but install the required version from pyenv. The version is OK if you install the latest version of 2 series and 3 series.

Python installation instructions

Use pyenv to see a list of installable versions.

$ pyenv install -l

Install python 3 series (3.5.2) from pyenv.

$ pyenv install  3.5.2

Next, install python 2 series (2.7.12) from pyenv.

$ pyenv install  2.7.12

Set the version to be used as a whole.

$ pyenv global 3.5.2

Confirm that the installation is complete.

$ pyenv versions

Install virtualenv

What is virtualenv?

A package that allows you to create a virtual environment for Python. You can change the Python version for each project, or install and run the required packages separately.

Virtualenv installation procedure

Install virtualenv from homebrew.

$ brew install pyenv-virtualenv

Set environment variables for the shell.

$ export PYENV_ROOT=$HOME/.pyenv
$ export PATH=$PYENV_ROOT/bin:$PATH
$ eval "$(pyenv init -)"

Supplement

I don't use anaconda. The reason is that by entrusting all library management to anaconda, trouble may occur when installing other packages with pip.

in conclusion

If you have any questions or mistakes, please comment. I hope that what my friends have taught me will help more people.

Recommended Posts

Anyone can understand how to build an initial environment for Python on Mac September 2016 (pyenv + virutalenv)
Build a Python virtual environment that anyone can understand September 2016 (pyenv + virutalenv)
How to build an environment for using multiple versions of Python on Mac
How to rebuild python environment from pyenv on Mac environment (El Capitan)
[Sakura Rental Server] (For beginners) How to build an environment for Python, pyenv, and Flask. | For csh
Try to build python and anaconda environment on Mac (by pyenv, conda)
How to build a Django (python) environment on docker
Build a Python environment on your Mac using pyenv
How to build a Python environment on amazon linux 2
How to build a beautiful Python environment on a new Mac and install Jupter Notebook
I tried to build an environment for machine learning with Python (Mac OS X)
Build an environment for machine learning using Python on MacOSX
How to build a new python virtual environment on Ubuntu
How to build a Python environment using Virtualenv on Ubuntu 18.04 LTS
Build an environment for Blender built-in Python
How to erase Python 2.x on Mac.
Build Python environment with Anaconda on Mac
Things to watch out for when creating a Python environment on a Mac
After buying a new Mac, use pyenv + poetry to build a Python environment.
[Definitive Edition] Building an environment for learning "machine learning" using Python on Mac
For beginners to build an Anaconda environment. (Memo)
Build python environment with pyenv on EC2 (ubuntu)
[Latest] How to build Java environment on Ubuntu
Building an environment for executing Python scripts (for mac)
Building an Anaconda environment for Python with pyenv
Build a Python environment on Mac (Mountain Lion)
Building an environment for matplotlib + cartopy on Mac
Build a Python development environment on your Mac
How to build Java environment on Ubuntu (Linux)
How to build an environment when you want to use python2.7 after installing Anaconda3
Notes from installing Homebrew to building an Anaconda environment for Python with pyenv
How to prepare an environment with different python version and package for each project with pyenv-virtualenv on Amazon Linux
Install Python3 on Mac and build environment [Definitive Edition]
Build an interactive environment for machine learning in Python
[Python] Building an environment for competitive programming with Atom (input () can be used!) [Mac]
How to set up a Python environment using pyenv
Build a local development environment for Laravel6.X on Mac
Building an environment for "Tello_Video" on Mac OS X
Build a machine learning Python environment on Mac OS
Build a Python development environment on Mac OS X
How to create a Python 3.6.0 environment by putting pyenv on Amazon Linux and Ubuntu
Build a Python development environment using pyenv on MacOS
Install Python environment on local PC (pyenv, venv on Mac)
Python environment construction on Mac (pyenv, virtualenv, anaconda, ipython notebook)
Build a machine learning environment on mac (pyenv, deeplearning, opencv)
How to install Python2.7 python3.5 with pyenv (on RHEL5 CentOS5) (2016 Nov)
Create a Python (pyenv / virtualenv) development environment on Mac (Homebrew)
Build an Ubuntu python development environment on Google Cloud Platform
Introducing Kaggle's Docker Image on Windows to build an environment
Build an environment on windows10 where you can try MXNet
How to make a Python package (written for an intern)
Build a python data analysis environment on Mac (El Capitan)
How to build a python2.7 series development environment with Vagrant
Build a Python extension for E-Cell 4 on Mac OSX (Yosemite)
Building an environment to execute python programs on AWS EC2
An introduction to Python that even monkeys can understand (Part 1)
An introduction to Python that even monkeys can understand (Part 2)
Create a virtual environment for python on mac [Very easy]
Build a python environment on CentOS 7.7 for your home server
Python environment construction For Mac
Update python on Mac to 3.7-> 3.8