Skip to content

Instantly share code, notes, and snippets.

Embed
What would you like to do?
{
"cells": [
{
"metadata": {
"slideshow": {
"slide_type": "slide"
}
},
"cell_type": "markdown",
"source": "# Anaconda and (Other) Python Distributions\n<br />\n### DesertPy Lightning Talk, May 2015\n<br />\n### Ashley Anderson\n[@aganders3](twitter.com/aganders3) on Twitter or aganders3@gmail.com"
},
{
"metadata": {
"slideshow": {
"slide_type": "slide"
}
},
"cell_type": "markdown",
"source": "## Anaconda : Python :: Debian : Linux\n\nAnaconda is a Python distribution. A Python distribution is analagous to a Linux distribution.\n\nOther distributions:\n* \"Python\" aka \"CPython\" (from python.org)\n* Enthought Canopy (formerly EPD)\n* Python(x,y)\n\n<div style=\"margin:auto\"><img src=\"images/anaconda-logo.png\" style=\"height:128px;float:left\"><img src=\"images/psf-logo.png\" style=\"height:128px;float:left\"><img src=\"images/canopy-logo.png\" style=\"height:128px;float:left\"><img src=\"images/pythonxy-logo.png\" style=\"height:128px;float:left\"></div>\n<div style=\"clear: both;\"></div>"
},
{
"metadata": {
"slideshow": {
"slide_type": "subslide"
}
},
"cell_type": "markdown",
"source": "## It's nothing new\n\nA Python *distribution* is distinct from an alternative *implementation* (e.g. PyPy). It's (likely) just a re-packaged version of CPython, with additional libraries or programs.\n"
},
{
"metadata": {
"slideshow": {
"slide_type": "fragment"
}
},
"cell_type": "markdown",
"source": "## Yes, they're selling stuff\nMany distributions are a foot-in-the-door for upselling add-ons (e.g. MKL Optimizations), training, or consulting services."
},
{
"metadata": {
"slideshow": {
"slide_type": "slide"
}
},
"cell_type": "markdown",
"source": "## What's in the box?\n\nMost distributions aim to enable \"scientific\" computing. Scientists often need tools for computation, but many don't have prior development experience. Distributions provide them a ready-to-use environment.\n\nIncluded in Anaconda (~280 MB vs. ~25 MB for vanilla Python):\n* Python and the standard library\n* [\"Full SciPy Stack\"](http://www.scipy.org/stackspec.html#stackspec) aka the PyData Stack\n * NumPy\n * SciPy\n * Matplotlib\n * IPython\n * Pandas\n* [SciKit-*, tornado, flask, PyQT, spyder, Cython, Numba, ...](http://docs.continuum.io/anaconda/pkg-docs.html)\n* `conda`"
},
{
"metadata": {
"slideshow": {
"slide_type": "slide"
}
},
"cell_type": "markdown",
"source": "##[`conda`](http://conda.pydata.org) : a package and environment manager\n* Install/manage binary packages - not just Python libs\n* Implemented in Python, BSD license\n* Create your own packages\n* Manage dependencies in environments\n* Works alongside `pip`\n* Comes with Anaconda, or standalone as Miniconda (~20 MB)"
},
{
"metadata": {
"slideshow": {
"slide_type": "subslide"
}
},
"cell_type": "markdown",
"source": "[<img src=\"images/xkcd-standards.png\" style=\"width:90%;margin:auto\" title=\"Fortunately, the charging one has been solved now that we've all standardized on mini-USB. Or is it micro-USB? Shit.\">](https://xkcd.com/927/)"
},
{
"metadata": {
"collapsed": false,
"slideshow": {
"slide_type": "subslide"
},
"trusted": true
},
"cell_type": "code",
"source": "!conda",
"execution_count": 2,
"outputs": [
{
"output_type": "stream",
"name": "stdout",
"text": "usage: conda [-h] [-V] [--debug] command ...\n\nconda is a tool for managing and deploying applications, environments and packages.\n\nOptions:\n\npositional arguments:\n command\n info Display information about current conda install.\n help Displays a list of available conda commands and their help strings.\n list List linked packages in a conda environment.\n search Search for packages and display their information. The input is a regular expression. To perform a search\n with a search string that starts with a -, separate the search from the options with --, like 'conda search\n -- -h'. A * in the results means that package is installed in the current environment. A . means that\n package is not installed but is cached in the pkgs directory.\n create Create a new conda environment from a list of specified packages.\n install Install a list of packages into a specified conda environment.\n update Update conda packages to the current version.\n remove Remove a list of packages from a specified conda environment.\n uninstall Alias for conda remove. See conda remove --help.\n run Launches an application installed with Conda.\n config Modify configuration values in .condarc. This is modeled after the git config command. Writes to the user\n .condarc file (/Users/ash/.condarc) by default.\n init Initialize conda into a regular environment (when conda was installed as a Python package, e.g. using pip).\n (DEPRECATED)\n clean Remove unused packages and caches.\n package Low-level conda package utility. (EXPERIMENTAL)\n bundle Create or extract a \"bundle package\" (EXPERIMENTAL)\n\noptional arguments:\n -h, --help Show this help message and exit.\n -V, --version Show the conda version number and exit.\n --debug Show debug output.\n\nexternal commands:\n build tool for building conda packages\n convert various tools to convert conda packages\n develop Install a Python package in 'development mode'. This works by creating a conda.pth file in site-packages, and using setup.py\n to determine any entry-points to install.\n env positional arguments:\n {create,export,list,remove,update}\n create Create an environment based on an environment file\n export Export a given environment\n list List the Conda environments\n remove Remove an environment\n update Update the current environment based on environment file\n index Update package index metadata files in given directories\n metapackage tool for building conda metapackages. A metapackage is a package with no files, only metadata\n pipbuild tool for building conda packages just using pip install\n skeleton create skeleton recipes for packages from hosting sites\n"
}
]
},
{
"metadata": {
"collapsed": false,
"slideshow": {
"slide_type": "subslide"
},
"trusted": true
},
"cell_type": "code",
"source": "!conda search pyqt",
"execution_count": 1,
"outputs": [
{
"output_type": "stream",
"name": "stdout",
"text": "Fetching package metadata: ....\npyqt 4.10.4 py34_0 defaults \n 4.10.4 py33_0 defaults \n * 4.10.4 py27_0 defaults \n 4.10.4 py26_0 defaults \n 4.11.3 py34_0 defaults \n 4.11.3 py33_0 defaults \n 4.11.3 py27_0 defaults \n 4.11.3 py26_0 defaults \n"
}
]
},
{
"metadata": {
"slideshow": {
"slide_type": "fragment"
}
},
"cell_type": "markdown",
"source": "<sup>The `*` indicates the currently installed version</sup>"
},
{
"metadata": {
"collapsed": false,
"slideshow": {
"slide_type": "subslide"
},
"trusted": true
},
"cell_type": "code",
"source": "!conda list",
"execution_count": 11,
"outputs": [
{
"output_type": "stream",
"name": "stdout",
"text": "# packages in environment at /opt/gpi/local/anaconda:\n#\n_license 1.1 py27_0 \nabstract-rendering 0.5.1 np19py27_0 \nanaconda 2.1.0 np19py27_0 \nargcomplete 0.8.1 py27_0 \nastropy 0.4.2 np19py27_0 \natom 0.3.9 py27_0 \nautopep8 1.0.4 <pip>\nbackports.ssl-match-hostname 3.4.0.2 <pip>\nbeautiful-soup 4.3.2 py27_0 \nbeautifulsoup4 4.3.2 <pip>\nbinstar 0.7.1 py27_0 \nbitarray 0.8.1 py27_0 \nblaze 0.6.3 np19py27_0 \nblz 0.6.2 np19py27_0 \nbokeh 0.8.2 np19py27_0 \nboto 2.32.1 py27_0 \ncasuarius 1.1 py27_0 \ncdecimal 2.3 py27_0 \ncffi 0.8.6 py27_0 \nchaco 4.4.1 np19py27_0 \ncolorama 0.3.3 py27_0 \nconda 3.12.0 py27_0 \nconda-build 1.8.2 py27_0 \nconda-env 2.1.4 py27_0 \nconfigobj 5.0.6 py27_0 \ncryptography 0.5.4 py27_0 \ncurl 7.38.0 0 \ncython 0.21 py27_0 \ncytoolz 0.7.0 py27_0 \ndatashape 0.3.0 np19py27_1 \ndateutil 2.1 py27_2 \ndecorator 3.4.0 py27_0 \ndocutils 0.12 py27_0 \ndynd-python 0.6.5 np19py27_0 \nenable 4.3.0 np19py27_2 \nenaml 0.9.8 py27_0 \nflask 0.10.1 py27_1 \nfreetype 2.4.10 1 \nfuture 0.13.1 py27_0 \nfutures 2.1.6 py27_0 \ngevent 1.0.1 py27_0 \ngevent-websocket 0.9.3 py27_0 \ngreenlet 0.4.5 py27_0 \ngrin 1.2.1 py27_1 \nh5py 2.3.1 np19py27_0 \nhdf5 1.8.13 0 \nipython 3.1.0 py27_0 \nipython-notebook 3.1.0 py27_1 \nipython-qtconsole 2.2.0 py27_0 \nitsdangerous 0.24 py27_0 \njdcal 1.0 py27_0 \njinja2 2.7.3 py27_1 \njpeg 8d 1 \njsonschema 2.4.0 py27_0 \nkiwisolver 0.1.3 py27_0 \nlabjackpython-4-24 2014 <pip>\nlauncher 1.0.0 1 \nlcms 1.19 0 \nlibdynd 0.6.5 0 \nlibpng 1.5.13 1 \nlibsodium 0.4.5 0 \nlibtiff 4.0.2 1 \nlibxml2 2.9.0 1 \nlibxslt 1.1.28 2 \nllvm 3.3 0 \nllvmpy 0.12.7 py27_0 \nlxml 3.4.0 py27_0 \nmarkupsafe 0.23 py27_0 \nmatplotlib 1.4.0 np19py27_0 \nmistune 0.5.1 py27_1 \nmock 1.0.1 py27_0 \nmultipledispatch 0.4.7 py27_0 \nnetworkx 1.9.1 py27_0 \nnibabel 2.0.0 <pip>\nnipype 0.10.0 <pip>\nnltk 3.0.0 np19py27_0 \nnode-webkit 0.10.1 0 \nnose 1.3.4 py27_0 \nnumba 0.14.0 np19py27_0 \nnumexpr 2.3.1 np19py27_0 \nnumpy 1.9.2 py27_0 \nopencv 2.4.8 np17py27_2 \nopenpyxl 1.8.5 py27_0 \nopenssl 1.0.1k 1 \npandas 0.16.0 np19py27_1 \npatsy 0.3.0 np19py27_0 \npep8 1.5.7 py27_0 \npil 1.1.7 py27_1 \npip 6.1.1 py27_0 \nply 3.4 py27_0 \npsutil 2.1.1 py27_0 \nptyprocess 0.4 py27_0 \npy 1.4.25 py27_0 \npyaudio 0.2.7 py27_0 \npycosat 0.6.1 py27_0 \npycparser 2.10 py27_0 \npycrypto 2.6.1 py27_0 \npycurl 7.19.5 py27_1 \npyface 4.4.0 py27_0 \npyflakes 0.8.1 py27_0 \npygments 2.0.2 py27_0 \npyopengl 3.0.2 py27_0 \npyopenssl 0.14 py27_0 \npyparsing 2.0.1 py27_0 \npyqt 4.10.4 py27_0 \npytables 3.1.1 np19py27_0 \npytest 2.6.3 py27_0 \npython 2.7.9 1 \npython-dateutil 2.4.2 py27_0 \npython.app 1.2 py27_3 \npytz 2015.2 py27_0 \npyyaml 3.11 py27_0 \npyzmq 14.6.0 py27_0 \nqimage2ndarray 1.4 <pip>\nqt 4.8.5 3 \nreadline 6.2 2 \nredis 2.6.9 0 \nredis-py 2.9.1 py27_0 \nrequests 2.7.0 py27_0 \nrope 0.9.4 py27_1 \nrunipy 0.1.1 py27_0 \nscikit-image 0.10.1 np19py27_0 \nscikit-learn 0.15.2 np19py27_0 \nscipy 0.14.0 np19py27_0 \nsetuptools 15.2 py27_0 \nsimpleitk 0.8.1 py27_0 \nsip 4.15.5 py27_0 \nsix 1.9.0 py27_0 \nsockjs-tornado 1.0.1 py27_0 \nsphinx 1.2.3 py27_0 \nspyder 2.3.1 py27_1 \nspyder-app 2.3.1 py27_0 \nsqlalchemy 0.9.7 py27_0 \nsqlite 3.8.4.1 1 \nssl_match_hostname 3.4.0.2 py27_0 \nstatsmodels 0.5.0 np19py27_2 \nsympy 0.7.5 py27_0 \ntables 3.1.1 <pip>\nterminado 0.5 py27_0 \ntk 8.5.18 0 \ntoolz 0.7.0 py27_0 \ntornado 4.1 py27_0 \ntraits 4.4.0 py27_0 \ntraitsui 4.4.0 py27_0 \nujson 1.33 py27_0 \nunicodecsv 0.9.4 py27_0 \nwerkzeug 0.10.4 py27_0 \nwxpython 3.0 py27_0 \nwxpython-common 3.0.0.0 <pip>\nxlrd 0.9.3 py27_0 \nxlsxwriter 0.5.7 py27_0 \nxlwt 0.7.5 py27_0 \nyaml 0.1.4 1 \nzeromq 4.0.5 0 \nzlib 1.2.8 0 \n"
}
]
},
{
"metadata": {
"slideshow": {
"slide_type": "slide"
}
},
"cell_type": "markdown",
"source": "## Conda Environments"
},
{
"metadata": {
"collapsed": false,
"slideshow": {
"slide_type": "subslide"
},
"trusted": true
},
"cell_type": "code",
"source": "!source activate tempura",
"execution_count": 40,
"outputs": [
{
"output_type": "stream",
"name": "stdout",
"text": "discarding /opt/gpi/local/anaconda/bin from PATH\nprepending /opt/gpi/local/anaconda/envs/tempura/bin to PATH\n"
}
]
},
{
"metadata": {
"slideshow": {
"slide_type": "fragment"
}
},
"cell_type": "markdown",
"source": "A `conda` environment is just a directory. Activating it adds it to your `PATH`.\n<br />\nHere's what's in it:"
},
{
"metadata": {
"collapsed": false,
"slideshow": {
"slide_type": "fragment"
},
"trusted": true
},
"cell_type": "code",
"source": "!ls /opt/gpi/local/anaconda/envs/tempura",
"execution_count": 36,
"outputs": [
{
"output_type": "stream",
"name": "stdout",
"text": "\u001b[1m\u001b[36mExamples\u001b[m\u001b[m \u001b[1m\u001b[36mbin\u001b[m\u001b[m \u001b[1m\u001b[36mconda-meta\u001b[m\u001b[m \u001b[1m\u001b[36minclude\u001b[m\u001b[m \u001b[1m\u001b[36mlib\u001b[m\u001b[m \u001b[1m\u001b[36mpython.app\u001b[m\u001b[m \u001b[1m\u001b[36mshare\u001b[m\u001b[m \u001b[1m\u001b[36mssl\u001b[m\u001b[m\r\n"
}
]
},
{
"metadata": {
"slideshow": {
"slide_type": "fragment"
}
},
"cell_type": "markdown",
"source": "Shared packages are hardlinked into each environment to save space, etc."
},
{
"metadata": {
"collapsed": false,
"slideshow": {
"slide_type": "fragment"
},
"trusted": true
},
"cell_type": "code",
"source": "!ls /opt/gpi/local/anaconda/envs/tempura/lib/python2.7/site-packages",
"execution_count": 37,
"outputs": [
{
"output_type": "stream",
"name": "stdout",
"text": "Flask-0.10.1-py2.7.egg-info numpy-1.9.2-py2.7.egg-info\r\n\u001b[1m\u001b[36mIPython\u001b[m\u001b[m \u001b[1m\u001b[36mpandas\u001b[m\u001b[m\r\nJinja2-2.7.3-py2.7.egg-info pandas-0.16.0-py2.7-macosx-10.5-x86_64.egg-info\r\n\u001b[1m\u001b[36mLabJackPython-4_24_2014-py2.7.egg-info\u001b[m\u001b[m \u001b[1m\u001b[36mpip\u001b[m\u001b[m\r\nLabJackPython.py pip-6.1.1-py2.7.egg-info\r\nLabJackPython.pyc \u001b[1m\u001b[36mpygments\u001b[m\u001b[m\r\nMarkupSafe-0.23-py2.7-macosx-10.5-x86_64.egg-info \u001b[1m\u001b[36mpython_dateutil-2.4.2-py2.7.egg-info\u001b[m\u001b[m\r\nModbus.py \u001b[1m\u001b[36mpytz\u001b[m\u001b[m\r\nModbus.pyc pytz-2015.2-py2.7.egg-info\r\nPyYAML-3.11-py2.7.egg-info pyzmq-14.6.0-py2.7.egg-info\r\nPygments-2.0.2-py2.7.egg-info \u001b[1m\u001b[36mrequests\u001b[m\u001b[m\r\nREADME requests-2.7.0-py2.7.egg-info\r\nWerkzeug-0.10.4-py2.7.egg-info setuptools-15.2-py2.7.egg\r\n_yaml.so\u001b[m\u001b[m setuptools.pth\r\n\u001b[1m\u001b[36mbackports\u001b[m\u001b[m six-1.9.0-py2.7.egg-info\r\nbackports.ssl_match_hostname-3.4.0.2-py2.7.egg-info six.py\r\n\u001b[1m\u001b[36mbokeh\u001b[m\u001b[m six.pyc\r\nbokeh-0.8.2-py2.7.egg-info skymote.py\r\n\u001b[1m\u001b[36mcolorama\u001b[m\u001b[m skymote.pyc\r\ncolorama-0.3.3-py2.7.egg-info \u001b[1m\u001b[36mtornado\u001b[m\u001b[m\r\n\u001b[1m\u001b[36mdateutil\u001b[m\u001b[m tornado-4.1-py2.7.egg-info\r\n\u001b[1m\u001b[36mflask\u001b[m\u001b[m u12.py\r\n\u001b[1m\u001b[36mgevent\u001b[m\u001b[m u12.pyc\r\ngevent-1.0.1-py2.7.egg-info u3.py\r\ngevent_websocket-0.9.3-py2.7.egg-info u3.pyc\r\n\u001b[1m\u001b[36mgeventwebsocket\u001b[m\u001b[m u6.py\r\ngreenlet-0.4.6-py2.7.egg-info u6.pyc\r\ngreenlet.so\u001b[m\u001b[m ue9.py\r\nipython-3.1.0-py2.7.egg-info ue9.pyc\r\nitsdangerous-0.24-py2.7.egg-info ujson-1.33-py2.7.egg-info\r\nitsdangerous.py ujson.so\u001b[m\u001b[m\r\nitsdangerous.pyc \u001b[1m\u001b[36mwerkzeug\u001b[m\u001b[m\r\n\u001b[1m\u001b[36mjinja2\u001b[m\u001b[m \u001b[1m\u001b[36myaml\u001b[m\u001b[m\r\n\u001b[1m\u001b[36mmarkupsafe\u001b[m\u001b[m \u001b[1m\u001b[36mzmq\u001b[m\u001b[m\r\n\u001b[1m\u001b[36mnumpy\u001b[m\u001b[m\r\n"
}
]
},
{
"metadata": {
"slideshow": {
"slide_type": "subslide"
}
},
"cell_type": "markdown",
"source": "What executables are added in the `bin` directory?"
},
{
"metadata": {
"collapsed": false,
"slideshow": {
"slide_type": "fragment"
},
"trusted": true
},
"cell_type": "code",
"source": "!ls /opt/gpi/local/anaconda/envs/tempura/bin",
"execution_count": 38,
"outputs": [
{
"output_type": "stream",
"name": "stdout",
"text": "2to3\u001b[m\u001b[m easy_install\u001b[m\u001b[m ipcontroller2\u001b[m\u001b[m ipython2\u001b[m\u001b[m \u001b[32mpython\u001b[m\u001b[m pythonw\u001b[m\u001b[m\r\n\u001b[32mactivate\u001b[m\u001b[m \u001b[32measy_install-2.7\u001b[m\u001b[m ipengine\u001b[m\u001b[m irunner\u001b[m\u001b[m \u001b[32mpython-config\u001b[m\u001b[m smtpd.py\u001b[m\u001b[m\r\nbokeh-server\u001b[m\u001b[m f2py\u001b[m\u001b[m ipengine2\u001b[m\u001b[m openssl\u001b[m\u001b[m python.app\u001b[m\u001b[m sqlite3\u001b[m\u001b[m\r\nc_rehash\u001b[m\u001b[m idle\u001b[m\u001b[m iplogger\u001b[m\u001b[m pip\u001b[m\u001b[m \u001b[32mpython2\u001b[m\u001b[m tclsh8.5\u001b[m\u001b[m\r\n\u001b[32mconda\u001b[m\u001b[m ipcluster\u001b[m\u001b[m iptest\u001b[m\u001b[m pycolor\u001b[m\u001b[m \u001b[32mpython2-config\u001b[m\u001b[m websocket_worker.py\u001b[m\u001b[m\r\ncurve_keygen\u001b[m\u001b[m ipcluster2\u001b[m\u001b[m iptest2\u001b[m\u001b[m pydoc\u001b[m\u001b[m python2.7\u001b[m\u001b[m wish8.5\u001b[m\u001b[m\r\n\u001b[32mdeactivate\u001b[m\u001b[m ipcontroller\u001b[m\u001b[m ipython\u001b[m\u001b[m pygmentize\u001b[m\u001b[m python2.7-config\u001b[m\u001b[m\r\n"
}
]
},
{
"metadata": {
"slideshow": {
"slide_type": "fragment"
}
},
"cell_type": "markdown",
"source": "Oh hey, `pip` is in there!\n<br />\nUse `pip install` and the package will be installed in your current `conda` environment.\n<br />\n`conda` recognizes `pip` installed packages, but can't manage or move them."
},
{
"metadata": {
"collapsed": false,
"slideshow": {
"slide_type": "fragment"
},
"trusted": true
},
"cell_type": "code",
"source": "!conda list labjack",
"execution_count": 39,
"outputs": [
{
"output_type": "stream",
"name": "stdout",
"text": "# packages in environment at /opt/gpi/local/anaconda:\n#\nlabjackpython-4-24 2014 <pip>\n"
}
]
},
{
"metadata": {
"slideshow": {
"slide_type": "slide"
}
},
"cell_type": "markdown",
"source": "## Additional Links For the Curious or Enthusiastic\n\n* [Continuum Analytics](http://continuum.io) - The people who make Anaconda\n* [Binstar](http://www.binstar.com) - Public (free) and private hosting for `conda` packages\n* [Alternative Implementations and Distributions](https://www.python.org/download/alternatives/) - Listed on Python.org\n"
}
],
"metadata": {
"kernelspec": {
"name": "python2",
"display_name": "Python 2",
"language": "python"
},
"language_info": {
"mimetype": "text/x-python",
"nbconvert_exporter": "python",
"name": "python",
"pygments_lexer": "ipython2",
"version": "2.7.10",
"file_extension": ".py",
"codemirror_mode": {
"version": 2,
"name": "ipython"
}
},
"celltoolbar": "Slideshow"
},
"nbformat": 4,
"nbformat_minor": 0
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
You can’t perform that action at this time.