Skip to content

Installation

Since this package contains C++ source code, pip needs a C++ compiler to install PySurvival.

1 - Installing C++ compiler

On MacOS

  1. Install brew - go on http://brew.sh/ and follow the provided instructions
  2. Install the latest version of gcc with the command :

    • If you have never installed gcc, use:

      brew install gcc
      

    • If you have already installed gcc and want the latest version:

      brew upgrade gcc
      

  3. Get the list all the gcc files with the command:

    brew ls gcc
    PySurvival - List of gcc variables

  4. Assign the environment variables CC and CXX to the previously found addresses, by entering the following lines in the terminal:

    export CXX=/usr/local/Cellar/gcc/8.2.0/bin/g++-8
    export CC=/usr/local/Cellar/gcc/8.2.0/bin/gcc-8

Note: As of October 18, 2018, the latest version on MacOS is 8.2.0, hence the use of 8.2.0; feel free to use the version that matches your situation instead.


On Linux

CentOS7

  1. Install GCC with the command :

    sudo yum install centos-release-scl
    sudo yum install devtoolset-8-gcc devtoolset-8-gcc-c++  -y
    
    Note: As of March 2019, the latest version of gcc is 8, hence the use of devtoolset-8; feel free to use the version that matches your situation instead.

  2. Assign the environment variables CC and CXX to the appropriate files:

    export CXX=/opt/rh/devtoolset-8/root/usr/bin/x86_64-redhat-linux-g++
    export CC=/opt/rh/devtoolset-8/root/usr/bin/x86_64-redhat-linux-gcc
    

Ubuntu

  1. Install GCC with the command :

    sudo apt install gcc-8 g++-8
    
    Note: As of March 2019, the latest version of gcc is 8, hence the use of gcc-8 g++-8; feel free to use the version that matches your situation instead.

  2. Assign the environment variables CC and CXX to the appropriate files:

    export CXX=/usr/bin/g++-8
    export CC=/usr/bin/gcc-8
    


The easiest way to install pySurvival is to use to pip:

pip install pysurvival

Potential Issues

Issues with matplotlib on MacOS

If you encounter the following error:

Error with matplotlib

RuntimeError: Python is not installed as a framework. The Mac OS X backend will not be able to function correctly if Python is not installed as a framework.

You'll need to ensure that there exists a file ~/.matplotlib/matplotlibrc containing the code: backend: TkAgg. To do this, run the following code in your Terminal:

cd
echo "backend: TkAgg" >> ~/.matplotlib/matplotlibrc