Installation
Since this package contains C++ source code, pip needs a C++ compiler to install PySurvival.
1 - Installing C++ compiler
On MacOS
- Install brew - go on http://brew.sh/ and follow the provided instructions
-
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
-
-
Get the list all the gcc files with the command:
brew ls gcc
-
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
-
Install GCC with the command :
Note: As of March 2019, the latest version of gcc is 8, hence the use ofsudo yum install centos-release-scl sudo yum install devtoolset-8-gcc devtoolset-8-gcc-c++ -y
devtoolset-8
; feel free to use the version that matches your situation instead. -
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
-
Install GCC with the command :
Note: As of March 2019, the latest version of gcc is 8, hence the use ofsudo apt install gcc-8 g++-8
gcc-8 g++-8
; feel free to use the version that matches your situation instead. -
Assign the environment variables CC and CXX to the appropriate files:
export CXX=/usr/bin/g++-8 export CC=/usr/bin/gcc-8
2 - Installation via from PyPI (recommended)
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