Support

Installing Python with RStudio Server Pro and RStudio Connect

Follow

Overview

You can install Python on a server with RStudio Server Pro or RStudio Connect by following the steps to install Python from source at:

https://docs.rstudio.com/connect/admin/python.html#python-install

These steps to install Python, pip, and virtualenv are summarized below.

Note that you can repeat all of the steps in this article to install multiple versions of Python on a server.

 

Step 1) Specify Python version

Specify the version of Python that you want to install:

export PYTHON_VERSION=3.6.8
export PYTHON_MAJOR=3

A list of available Python versions can be found on python.org.

 

Step 2) Install Required Dependencies

You can install the dependencies required to build and run Python for your Linux distribution.

On RHEL/CentOS:

sudo yum-builddep -y python python-libs
sudo yum install -y libffi-devel zlib zlib-devel

On Ubuntu:

apt-get build-dep python
apt-get install libffi-dev libgdbm-dev libsqlite3-dev libssl-dev zlib1g-dev

On SUSE:

zypper install automake fdupes gcc gcc-c++ gcc-fortran gdbm-devel gettext-tools gmp-devel intltool libbz2-devel libexpat-devel libffi-devel libnsl-devel lzma-devel make ncurses-devel netcfg openssl-devel pkgconfig readline-devel sqlite-devel xz zlib-devel

 

Step 3) Download and Extract Python

Download and extract Python, then navigate into the Python directory:

curl -O https://www.python.org/ftp/python/${PYTHON_VERSION}/Python-${PYTHON_VERSION}.tgz
tar -xvzf Python-${PYTHON_VERSION}.tgz
cd Python-${PYTHON_VERSION}

 

Step 4) Build and Install Python

Configure, make, and install Python:

./configure --prefix=/opt/Python/${PYTHON_VERSION} --enable-shared --enable-ipv6 LDFLAGS=-Wl,-rpath=/opt/Python/${PYTHON_VERSION}/lib,--disable-new-dtags
make
sudo make install

 

Step 5) Install pip and virtualenv

Install pip and virtualenv into the version of Python that you just installed:

# Install pip
curl -O https://bootstrap.pypa.io/get-pip.py
sudo /opt/Python/${PYTHON_VERSION}/bin/python${PYTHON_MAJOR} get-pip.py

# Install virtualenv sudo /opt/Python/${PYTHON_VERSION}/bin/pip install virtualenv

 

Step 6) Verify Python Installation

Verify that Python is installed by running the following command:

/opt/Python/${PYTHON_VERSION}/bin/python${PYTHON_MAJOR} --version

 

Comments