Memo to switch between python2 series and 3 series in anaconda environment of mac (win is also added)

I'm new to python, so I want to try various libraries. However, I don't want to spend time rebuilding the environment by doing something strange. Therefore, I want an environment that does not affect the entire OS even if I do various things, and I am looking for various things.

setup

Building a conda environment

Use conda for the switching environment. I will try docker next time. This time, we will also introduce a tensorflow environment at the same time.

I don't want to break the mac environment, so First, download the anaconda formula from the following and install it. https://www.continuum.io/downloads

of course, $ bash Anaconda2-4.3.1-MacOSX-x86_64.sh But it seems that the minimum environment such as miniconda is fine.

Individual environment construction

Well, when conda comes in,

$ conda create -n py2tf python=2.7 anaconda $ source activate py2tf You can enter the environment with the above source activate. When entering the environment, characters such as (py2tf) are added to the beginning and can be identified.

(py2tf)$ conda install -c conda-forge tensorflow (py2tf)$ source deactivate

In the above example, tensorflow is also installed in addition to the 2.7 environment. In addition to tensorflow, there are many that support conda installation. It seems that additional installation is possible with pip etc. even if it is not supported (see the link at the end of the book) What you install in conda does not affect other environments. (Recognition)

Then build 3.5 series $ conda create -n py3tf python=3.5 anaconda $ source activate py3tf (py3tf)$ conda install -c conda-forge tensorflow (py3tf)$ source deactivate

How to use

Enter the environment $ source activate py3tf

Get out of the environment (py3tf)$ source deactivate

List of created environment $ conda info -e

Search for environments in conda $ conda search tenorflow

update of conda $ conda update conda

Browse installed packages in your environment $ conda list If you run it in an environment, a list of packages in that environment. If you run it outside the environment, a list of packages included in the mac itself. Or, execute by specifying the environment $ conda list -n py3tf

Delete environment conda remove -n py3tf --all

Export the library installed by conda And build the environment from the above file conda list --export > conda_requirements.txt conda create -n my_new_env --file conda_requirements.txt Is the following environmental output method the mainstream?

Environment output, build environment from output file conda env export > environment.yml conda env create -f environment.yml

I referred to the following articles. https://gist.github.com/aphlysia/d5fcee79ff81b8272faf http://qiita.com/icoxfog417/items/02a80b93b5f1e95f2795 http://qiita.com/yubessy/items/2dd43551aa8308dc7eca


** For Windows 10 **

Download and install Anaconda from the website. (Executable file format)

PATH to python and conda. By default, it should be installed around the following. 'C:\Users"user name"\Anaconda3' 'C:\Users"user name"\Anaconda3\Scripts'

The rest is the same as for MAC.

Recommended Posts

Memo to switch between python2 series and 3 series in anaconda environment of mac (win is also added)
How to develop in a virtual environment of Python [Memo]
Difference between == and is in python
How to use is and == in Python
Try to build python and anaconda environment on Mac (by pyenv, conda)
The answer of "1/2" is different between python2 and 3
About the difference between "==" and "is" in python
How to switch between Linux and Mac shells
Difference between Ruby and Python in terms of variables
Indent behavior of json.dumps is different between python2 and python3
Python environment construction and SQL execution example to DB and memo of basic processing for statistics 2019
Comparison of how to use higher-order functions in Python 2 and 3
[Django] Memo to create an environment of Django + MySQL + Vue.js [Python]
Overview of Python virtual environment and how to create it
Python 2 series and 3 series (Anaconda edition)
Python> list> append () and extend ()> append: list is added | extend: list elements are added | + = to add list
Build a Python environment on your Mac with Anaconda and PyCharm
Difference in how to write if statement between ruby ​​and python
Environment construction of python and opencv
Difference between java and python (memo)
Difference between list () and [] in Python
Division of timedelta in Python 2.7 series
Install scrapy in python anaconda environment
Python environment construction memo on Mac
Python memo Anaconda installation (Mac only)
[Python] What to do when PEP8 is violated in the process of importing from the directory added to sys.path
install tensorflow in anaconda + python3.5 environment
There is no switch in python
Environment construction of python3.8 on mac
Python in is also an operator
[Python] How to save the installed package and install it in a new environment at once Mac environment
Python3.6 environment construction (using Win environment Anaconda)
[Introduction to Python] What is the difference between a list and a tuple?
Work memo to migrate and update Python 2 series scripts on the cloud to 3 series
Migration from Python2 to Python3 (Python2 is rebuilt as a virtual environment and coexists)
Implementation of particle filters in Python and application to state space models
What to do when the warning "The environment is in consistent ..." appears in the Anaconda environment
Switch the module to be loaded for each execution environment in Python
An engineer who has noticed the emo of cryptography is trying to implement it in Python and defeat it
[Python] Building an environment with Anaconda [Mac]
Differences in authenticity between Python and JavaScript
[Python] What is pandas Series and DataFrame?
Differences between Ruby and Python in scope
How to access environment variables in Python
Method to build Python environment in Xcode 6
Differences in syntax between Python and Java
Difference between @classmethod and @staticmethod in Python
Difference between append and + = in Python list
Difference between nonlocal and global in Python
The result of installing python in Anaconda
Build Python environment with Anaconda on Mac
To reference environment variables in Python in Blender
[Python3] Switch between Shift_JIS, UTF-8 and ASCII
How to add python module to anaconda environment
Easy introduction of python3 series and OpenCV3
Differences in multithreading between Python and Jython
Adding Series to columns in python pandas
Project Euler # 1 "Multiples of 3 and 5" in Python
I want to use Python in the environment of pyenv + pipenv on Windows 10
How to build an environment for using multiple versions of Python on Mac
Ubuntu 16.04 LTS, beginner memorandum of environment construction to switch anaconda version with pyenv