Did you know that Anaconda has been supporting Python 3 for more than half a year? While the Anaconda installers use Python 2.7, it is quite easy to create new additional environments that provide Python 3.3 (and soon Python 3.4), as well as many scientific packages. This blog explains how this is done in detail.
When you install Anaconda, which is a versioned collection of useful big data and scientific packages, you have basically two options. The first is to use the full installer, which is several hundred megabytes, but includes everything in one download, and is therefore convenient to put on USB flash drives. The second is to use the mini-installer Miniconda, which installs only a minimal environment, and use the conda package manager to download and install subsequent packages as-needed.
Starting from a regular Anaconda installation
If you have installed Anaconda from
the full installer, there is
a root environment which has Python 2.7 and all
What this means is that these packages are installed directly into the
install prefix which was selected during the install process.
The conda package manager
now allows creating new environments separately from the root environment.
Since these additional environments are completely separate, they may
contain a different major Python version. The following command would be
used to create an Anaconda Python 3 environment named
$ conda create -n py3k python=3 anaconda
anaconda are package
specifications, and it is the job of the
inside conda to find a consistent set of packages which satisfies these
As the root environment uses Python 2, we had to specify the major version explicitly.
After adding the binary directory of the newly created environment to the
PATH environment variable, which may be done using
$ source activate py3k
You are ready to use this Python 3 Anaconda environment.
Starting from Miniconda installation
Miniconda are installers which contain the conda package manager and Python. As conda works with either Python 2 or 3, Miniconda comes in two versions, i.e. the regular (which contains a Python 2 interpreter) and “Miniconda3” which comes with a Python 3 interpreter. This is the only difference between the two. So if you want a full Anaconda for Python 3 to be your root environment, you can first install Miniconda3, and then:
$ conda install anaconda
That is, you do not create a new environment, but simply install all Anaconda packages into your Python 3 root environment. You can still use the Miniconda3 setup to create Python 2 environments. However, as the default of the Python version is based on the Python version running conda, you now have to specify that you want to create an environment with Python 2 explicitly. For example:
$ conda create -n my_pandas python=2 pandas
Trying it out
Here is a small sample session, which shows how you create a Python 3 environment with IPython, activated it, and start it:
$ conda create -n py3k python=3 ipython ... $ source activate py3k prepending /home/ilan/a150/envs/py3k/bin to PATH (py3k)$ ipython Python 3.3.2 |Continuum Analytics, Inc.| (default, Aug 5 2013, 15:04:35) Type "copyright", "credits" or "license" for more information. IPython 1.1.0 -- An enhanced Interactive Python. ? -> Introduction and overview of IPython's features. %quickref -> Quick reference. help -> Python's own help system. object? -> Details about 'object', use 'object??' for extra details. In :Anaconda conda Python 3 comments powered by Disqus
Back to Blog→
- Anaconda Server
- Bayesian Data Analysis
- Big Data
- Boolean satisfiability problem
- IPython Notebook
- Open Source
- Practical Python
- Product Release
- Product Update
- Python 3
- Raspberry Pi
- SAT solver
- Social Media
- Thomson Reuters
- White Paper