IPython and the IPython Notebook have vast potential beyond their traditional use in the Python scientific programming community. Specifically, the Notebook is a great learning tool, and that’s something I plan to highlight in an upcoming talk at the New England Regional Developer (NERD) Summit.
Because the NERD mission is to reduce barriers for people entering IT (as opposed to having them waste years of their lives untangling Python package dependencies), the plan is to demo everything using the Anaconda Python installation. Overkill maybe, since even on Windows installing Python and IPython isn’t too terrible. That said:
- It’s important for those who aren’t proficient on the command line to jump right in.
- If people get hooked on Python and want to do more, they’ll have the important packages at the ready (Anaconda includes some important machine learning packages that are missing from the free version of its competitor, Enthought Canopy).
To understand the worst case pain scenario before recommending Anaconda to beginners, I installed it on Windows. So far, so good.
The only snafu I’ve hit so far is trying to get the IPython–>R integration working. This isn’t really a feature for beginners, but I want to show it because R is heavily used at local universities.
To be clear, this mess isn’t an Anaconda problem. However, if you’re using Anaconda on Windows and want to use IPython’s rmagic extension, here’s how.
- Install R.
- Add the directory with the R executables to your PATH. It has to be the directory with executables, not the main R folder. On a 64-bit machine, the directory is something like C:\Program Files\R\R-3.1.0\bin\x64.
- Add these two environment variables (h/t):
- R_HOME (path of the main R folder, e.g. C:\Program Files\R\R-3.1.0)
- R_USER (your Windows username).
- Restart Windows.
- Modify your Windows Python install registry key to point to your Anaconda Python location instead of the default Python installation (h/t). If you followed the default Anaconda install prompts (which installs for the current user, rather than all users on the machine), you’d change HKEY_CURRENT_USER\SOFTWARE\Python\PythonCore\2.7\InstallPath.
- Download and install Dr. Gohlke’s rpy2 Windows binary (grab version 2.4.0 or higher): http://www.lfd.uci.edu/~gohlke/pythonlibs/#rpy2.
- Change the registry key from step 5 back to it’s original value.
- Open an IPython notebook or terminal and load the rmagic extension:
- You should be able to test everything out using this sample code.
For comparison, these are the Ubuntu instructions.
- Install R:
sudo apt-get install r-base r-base-core r-base-html
- Install rpy2:
pip install rpy2