A memorandum of migration (coexistence) from Python 2 to Python 3 on Windows
Uninstall Python 2.7 from Program Changes / Removes
Introduced in Anaconda Go to the Anaconda site (https://www.continuum.io/downloads) and download the latest Anaconda (Python3) installer Run the installer
Select a place to put Anaconda
You will be asked if you want to add a PATH, so select "Yes" this time. If you do not select this you will have to add your own PATH The second checkbox is also "Yes"
Successful installation of Python 3
Build a virtual environment for Pyrhon2 in Anaconda3 using conda Execute the following at the command prompt Packages can be added later
# conda create --name [Virtual environment name] python=2.7(Favorite version) [package] ... [package]
conda create --name python27 python=2.7 numpy scipy pandas jupyter
#This time python2.I put 7 alone and added a package, but it is also possible to put anaconda
conda create -n anaconda2 python=2.7 anaconda
There should be a folder with the specified environment name in the ~ Anaconda3 / envs directory.
#Enter the virtual environment
# activate [Virtual environment name]
acitvate python27
#Get out of the virtual environment
# deactivate [Virtual environment name]
deactivate python27
Packages are not common in Python3 and Python2 environments, so you need to put the package you want to use in each environment.
You can enter the Python3 environment with conda or pip as usual To enter the Python2 virtual environment, enable the virtual environment once and then use conda or pip.
activate python27;conda install numpy
activate python27;pip install numpy
conda install --name python27 numpy #In the case of conda, you can also specify the environment name and enter it like this
pip install --name python27 numpy #This cannot be done ×
Allows you to select both Python 2 and Python 3 in your usual development environment 3.1 Jupyter As it is, even if you start jupyter that you put in Anaconda3, you can only select Python3
You need to do the work of adding a kernel
#First enable the virtual environment
activate python27
#You can add kernel with the following command
ipython kernel install --user --name=python27 --display-name=Python2
--name: environment name --display-name: The name displayed by jupyter
The added kernel resides in ~ AppData \ Roaming \ jupyter \ kernels If you want to remove a kernel, just remove it from this folder
This makes it possible to select Python 2 from juypter as well.
3.2 PyCharm
Select File → Setting → Project Interpreter Select the part indicated by the red circle Select Add Local
Select the virtual environment python.exe you just entered Anaconda3\envs\python27\python.exe Apply
Now you can also select Python2 in PyCharm
Building a python environment for those who aim to become data scientists 2016 http://qiita.com/y__sama/items/5b62d31cb7e6ed50f02c Settings for easy selection of multiple kernels in Jupyter http://qiita.com/tomochiii/items/8b937f15c79a0c3eae0e
Recommended Posts