From Python environment construction to virtual environment construction with anaconda

Introduction

I needed to use python for my research, so I will share the contents of the environment construction. First of all, in the case of mac, python2.7 is included in the system from the beginning.

pyenv You can manage multiple versions of python. It's like rbenv in Ruby.

We will install it immediately. There are several installation methods, but this time I will install it with Homebrew.

$ brew install pyenv

Then put it in your PATH.

 .bash_profile


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

You can see the list of installable pythons.

$ pyenv install -l

Anaconda Then install Anaconda. This is a package that allows you to install various packages in a batch in addition to python itself. Install using pyenv. This time, we will build the environment with version 2.x.

$ pyenv install anaconda-2.4.0

Now you have 2.x anaconda! This anaconda contains python2.7.

$ pyenv global anaconda-2.4.0
$ python --version
Python 2.7.12 :: Anaconda custom (x86_64)

By specifying the installed anaconda, it became anaconda python instead of the system! If you check the version of python, it will be Python 2.7.12.

Virtual environment construction

Next, I will build a virtual environment with anaconda. Development will be done in this virtual environment. If something happens, you can easily reset it and feel safe!

There is also a virtualenv to build a virtual environment with python, but you can also build a virtual environment with anaconda using something called conda!

$ conda create -n [The name of the virtual environment] python=2.7

You can easily build a virtual environment with this command.

$ conda env list

You can check the existing virtual environment with this command.

source activate [The name of the virtual environment]
source deactivate

You can enter the virtual environment with activate! Deactivate when you leave!

I stumbled once when activating. The problem is that pyenv and condo activate conflict!

http://qiita.com/y__sama/items/f732bb7bec2bff355b69

Let's add PATH.

Finally

We built a python environment this time! Compared to other languages, there are many things such as package management and version control, which makes me confused! pyenv => anaconda => virtual environment Like, the structure has many layers, but I think it could be made easier, especially if one environment is good. I'm glad I just had anaconda ...

That's all for building the python environment.

Recommended Posts

From Python environment construction to virtual environment construction with anaconda
Change Python 64bit environment to 32bit environment with Anaconda
[Python] Create a virtual environment with Anaconda
Virtual environment with Python 3.6
Collecting information from Twitter with Python (Environment construction)
[Node-RED] Execute Python on Anaconda virtual environment from Node-RED [Anaconda] [Python]
Python + Anaconda + Pycharm environment construction
Anaconda updated from 4.2.0 to 4.3.0 (python3.5 updated to python3.6)
Anaconda3 python environment construction procedure
Virtual environment construction with Docker + Flask (Python) + Jupyter notebook
From Kafka to KSQL --Easy environment construction with docker
Python development environment construction 2020 [From Python installation to poetry introduction]
Procedure to exe python file from Ubunts environment construction
Get started with Python! ~ ① Environment construction ~
Notes from installing Homebrew to building an Anaconda environment for Python with pyenv
Build python virtual environment with virtualenv
Create folders from '01' to '12' with python
Create a virtual environment with Python!
Python environment construction (pyenv, anaconda, tensorflow)
Building a virtual environment with Python 3
Python3 environment construction with pyenv-virtualenv (CentOS 7.3)
From Ubuntu 20.04 introduction to environment construction
pytorch @ python3.8 environment construction with pipenv
Python3.6 environment construction (using Win environment Anaconda)
OpenJTalk on Windows10 (Speak Japanese with Python from environment construction)
[Python] Anaconda environment construction (installation, startup, virtual environment, package management) Mac environment
From environment construction to deployment for flask + Heroku with Docker
Python environment construction
python environment construction
Python --Environment construction
Python environment construction
python environment construction
[Ubuntu 18.04] Python environment construction with pyenv + pipenv
Python (anaconda) development environment construction procedure (SpringToolsSuites) _2020.4
Vue.js + Flask environment construction memorandum ~ with Anaconda3 ~
[5 steps] Apply anaconda virtual environment to VScode
[Python] Road to snake charmer (1) Environment construction
Build Python environment with Anaconda on Mac
How to add python module to anaconda environment
Build a python virtual environment with pyenv
Add a Python virtual environment to VSCode
Let's get along with Python # 0 (Environment construction)
Web application created with Python + Flask (using VScode) # 1-Virtual environment construction-
From installing Ansible to building a Python environment in Vagrant's virtual environment
Call anaconda virtual environment from ubuntu terminal memorandum
Building a virtual environment for Mayavi dedicated to Python 3.6, Anaconda, Spyder users
How to create a Python virtual environment (venv)
MacOS 10.11 environment construction: Powerline with Anaconda and Dein.vim
From Kivy environment construction to displaying Hello World
python windows environment construction
Changes from Python 3.0 to Python 3.5
Changes from Python 2 to Python 3.0
Python explosive environment construction starting from zero (Mac)
Python environment construction (Anaconda + VSCode) @ Windows10 [January 2020 version]
homebrew python environment construction
Building an Anaconda environment for Python with pyenv
Building a Python environment with WLS2 + Anaconda + PyCharm
Python (Windows 10) Virtual Environment / Package with VS Code
Create a virtual environment with conda in Python
Python development environment construction
python virtual environment Pipenv