Try to build python and anaconda environment on Mac (by pyenv, conda)

As a memo in studying python

pyenv-Do not use virtualenv. (I tried to use it, but it didn't work) Write in the direction of switching the environment with conda. Since activate seems to be covered with pyenv, write in the direction of specifying activate of anaconda with the full path.

I was allowed to refer to this. http://qiita.com/y__sama/items/f732bb7bec2bff355b69

environment

Mac OS X El Capitan python 3.5.2 anaconda 4.3

1. Install pyenv and anaconda

・ Installation of pyenv

(1) With homebrew or git

brew install pyenv

or

git clone https://github.com/yyuu/pyenv.git ~/.pyenv

(2) Add settings to .bash_profile (.bashrc)

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

(3) Reread

source .bash_profile

・ Installation of anaconda

(1) Check the installable version of anaconda

pyenv install -l

(2) Anaconda installation

In the case of 3 system

pyenv install anaconda3-4.2.0

In the case of 2 system

pyenv install anaconda2-4.2.0

2. Build a virtual environment with conda and switch the environment with activate

(1) Switch the anaconda environment to global

pyenv global anaconda3-4.2.0

(2) Create a virtual environment with conda

conda create --name py3.5 python=3.5 anaconda

I couldn't do it without specifying the python version. Also, if you want to include the anaconda environment, you need "anaconda" after it.

(3) Move to the working folder and execute pyenv local

cd anaconda_sample
pyenv local anaconda3-4.2.0/envs/py3.5

(4) Return global to system (optional)

pyenv global system

(5) Activate and switch the environment

source $PYENV_ROOT/versions/anaconda3-4.2.0/bin/activate py3.5

Check python and anaconda versions

python -V
Python 3.5.2 :: Anaconda 4.3.0 (x86_64)

Try starting jupyter notebook (optional)

jupyter notebook

If you can start jupyter in your browser, it's OK (you should be able to start it because you also included anaconda)

(6) Deactivate the environment with deactivate

source $PYENV_ROOT/versions/anaconda3-4.2.0/bin/deactivate py3.5

(7) When switching the environment again, enter the working folder and activate

cd anaconda_sample
source $PYENV_ROOT/versions/anaconda3-4.2.0/bin/activate py3.5

3. (Bonus) Installation of ansible

I am building a development environment with ansible, so install it up to that point The environment is as follows. Python 2.7.13 Anaconda 4.3.0 ansible 2.2.1.0

(1) Anaconda installation (2 series)

pyenv install anaconda2-4.2.0

(2) Switch the anaconda environment to global

pyenv global anaconda2-4.2.0

(3) Create a virtual environment with conda

conda create --name ansible python=2.7 anaconda

You may not need to use "anaconda" at the back only with ansible. I put it on for the time being.

(4) Move to the working folder and execute pyenv local

cd anaconda_ansible
pyenv local anaconda2-4.2.0/envs/ansible

(5)activate

source $PYENV_ROOT/versions/anaconda2-4.2.0/bin/activate ansible

Check python and anaconda versions

python -V
Python 2.7.13 :: Anaconda 4.3.0 (x86_64)

(6) Install ansible with pip

pip install ansible

If you want to manage ansible with conda, refer to the URL below http://stangler.hatenablog.com/entry/2016/10/11/171115

Check the version of ansible

ansible --version
ansible 2.2.1.0

Impressions

The syntax for activate is a bit long, so please let me know if there is any better way. (I wonder if you should add an alias ...) I've been studying a lot with this for a while!

Recommended Posts

Try to build python and anaconda environment on Mac (by pyenv, conda)
Build Python environment with Anaconda on Mac
Build a Python environment on your Mac with Anaconda and PyCharm
Install Python3 on Mac and build environment [Definitive Edition]
Build a Python environment on your Mac using pyenv
Python environment construction on Mac (pyenv, virtualenv, anaconda, ipython notebook)
How to build a beautiful Python environment on a new Mac and install Jupter Notebook
How to create a Python 3.6.0 environment by putting pyenv on Amazon Linux and Ubuntu
Build Python3 and OpenCV environment on Ubuntu 18.04
Notes on building Python and pyenv on Mac
How to rebuild python environment from pyenv on Mac environment (El Capitan)
Python3 TensorFlow environment construction (Mac and pyenv virtualenv)
After buying a new Mac, use pyenv + poetry to build a Python environment.
Build python environment with pyenv on EC2 (ubuntu)
Build Python3.5 + matplotlib environment on Ubuntu 12 using Anaconda
Build a Python environment on Mac (Mountain Lion)
Introducing keras on virtual environment (pyenv: anaconda) on server by conda (tensorflow backend)
Build a Python development environment on your Mac
Notes on setting pyenv and python environment using Homebrew on Mac OS Marvericks
Try using tensorflow ① Build python environment and introduce tensorflow
Remove old pyenv environment on Mac and update
Create a Python3 environment with pyenv on Mac and display a NetworkX graph
Try importing MLB data on Mac and Python
Anyone can understand how to build an initial environment for Python on Mac September 2016 (pyenv + virutalenv)
How to build an environment for using multiple versions of Python on Mac
Install selenium on Mac and try it with python
Build a machine learning Python environment on Mac OS
How to build a Django (python) environment on docker
Build a Python development environment on Mac OS X
Build a Python development environment using pyenv on MacOS
Install Python environment on local PC (pyenv, venv on Mac)
How to build a Python environment on amazon linux 2
Build Python environment on Windows
Update python on Mac to 3.7-> 3.8
Build python environment on windows
Catalina on Mac and pyenv
Build a machine learning environment on mac (pyenv, deeplearning, opencv)
Create a Python (pyenv / virtualenv) development environment on Mac (Homebrew)
Building a Python environment on a Mac and using Jupyter lab
Install pyenv on MacBook Air and switch python to use
Build a python data analysis environment on Mac (El Capitan)
Build a Python environment and transfer data to the server
Building a Python environment on Mac
Python 3.6 on Windows ... and to Xamarin.
Anaconda python environment construction on Windows 10
Anaconda environment construction on Mac (2018 version)
Create a Python environment on Mac (2017/4)
Python environment construction memo on Mac
Install Python 3.7 Anaconda on MAC, but Python 2
Python environment construction (pyenv, anaconda, tensorflow)
Environment construction of python3.8 on mac
How to manage Python minor version (build virtual environment) on Windows (without Pyenv or WSL)
Build Python 3.8 + Pipenv environment on Ubuntu 18.04
Steps to install python3 on mac
Build a python3 environment on CentOS7
[Sakura Rental Server] (For beginners) How to build an environment for Python, pyenv, and Flask. | For csh
Update Python on Mac from 2 to 3
Build a 64-bit Python 2.7 environment with TDM-GCC and MinGW-w64 on Windows 7
How to build a Python environment using Virtualenv on Ubuntu 18.04 LTS
Install Anaconda on Mac and upload Jupyter (IPython) notebook to Anaconda Cloud
Try to implement and understand the segment tree step by step (python)