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
Mac OS X El Capitan python 3.5.2 anaconda 4.3
(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
(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
(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
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
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