Skip to content

Python Installation Instructions for RCloud

Gordon Woodhull edited this page Dec 2, 2017 · 1 revision

RCloud Python support

There are two levels of support - embedding Python in the R session and using Python cells in notebook. The latter requires the former.

Setting up Python 2.7.x for Redhat/CentOS

rpython2 requires Python 2.7.x. Redhat/CentOS/Fedora ship with Python 2.6.x

There is a need for setting up an alternative python 2.7 install since upgrading the system python is not an option as system libraries such as yum break with the update

To achieve the same please follow the blog write up at http://toomuchdata.com/2014/02/16/how-to-install-python-on-centos/

Use "--enable-shared" while configuring python make

yum groupinstall "Development tools"
yum install zlib-devel bzip2-devel openssl-devel ncurses-devel sqlite-devel readline-devel tk-devel gdbm-devel db4-devel libpcap-devel xz-devel

wget --no-check-certificate https://www.python.org/ftp/python/2.7.8/Python-2.7.8.tar.xz
tar xf Python-2.7.8.tar.xz
cd Python-2.7.8
./configure --prefix=/usr/local --enable-shared --enable-unicode=ucs4 LDFLAGS="-Wl,-rpath /usr/local/lib"
make && make altinstall
ln -s /usr/local/bin/python2.7 /usr/local/bin/python
ln -s /usr/local/bin/python2.7-config /usr/local/bin/python-config

Installing rpython2

Installing rpython2 (R package to embed Python) package

Make sure you have Python development files.

  • On Ubuntu

     sudo apt-get install python-dev
    
  • On OSX

     brew install python
    
  • On Redhat/CentOS

    • When you build python use the --enable-shared flag

Install R Python 2 [R Package from rforge]

  • On Ubuntu

     R -e 'install.packages("rpython2",,"http://rforge.net/",type="source")'
    
  • On Redhat/Fedora

    Note /usr/local/lib is where libpython2.7.so.1.0 is to be found after Python 2.7 alternative install. It is what --prefix flag indicates while making python 2.7

     echo "/usr/local/lib" >> /etc/ld.so.conf/python2.7.conf
     ldconfig
     R -e 'install.packages("rpython2",,"http://rforge.net/",type="source")'
    

After installation if you want to run rpython2 commands in RCloud, create an R cell and attach the rpython package using library(rpython2). Following this, you can run the rpython code in an R cell.

    library(rpython2)
    py.init()
    py.eval("print 2+3")

If you want full Python cell support available in the release of RCloud, you will also need IPython installed as follows:

Installing IPython

  • Installing IPython (for Ubuntu 14.04)

      sudo apt-get install python-dev python-zmq python-matplotlib ipython
    
  • Installing IPython (for Ubuntu 12.04-13.10)

    • Older Ubuntu versions come with IPython that is too old to use, so you have to use a PPA to install a more recent version:

      sudo apt-get install python-software-properties python-dev python-zmq python-matplotlib
      sudo add-apt-repository ppa:jtaylor/ipython
      sudo apt-get update 
      sudo apt-get install ipython
      

      (Note: for Ubuntu 14.04 you can use the same PPA as well to get IPython 2.x which is not required but more recent)

  • Installing IPython for Redhat/CentOs

    • You would need to setup easy_install for the newly setup Python 2.7

        curl https://bootstrap.pypa.io/ez_setup.py -o - | python2.7
      
    • You would require the following dependencies

        yum install libpng libpng-devel freetype freetype-devel
        easy_install-2.7 ipython pyzmq pip
        pip install matplotlib
      

Installing via pip

If you want to use latest manually compiled IPython, use pip instead of the above Ubuntu instructions. Note that ipython3 is not yet supported:

pip install ipython==2.4.1

Re-start RCloud create a Python cell and type some Python program. It should be executed successfully.

Installing on OSX We can't really cover all the possible dependencies, but some other dependencies that helped on OSX include:

brew install pkg-config
brew install freetype
pip install pyzmq
pip install matplotlib