ModuleNotFoundError: No module named 'sksurv' in python

Viewed 3188

I am trying to run survival analysis in python (pycharm) in linux, here is a part of the code

import numpy as np
import matplotlib.pyplot as plt
#matplotlib inline
import pandas as pd

from sklearn.impute import SimpleImputer
from sklearn.pipeline import make_pipeline
from sklearn.model_selection import train_test_split

from sksurv.datasets import load_flchain
from sksurv.linear_model import CoxPHSurvivalAnalysis

I get the error "ModuleNotFoundError: No module named 'sksurv'", I tried everything, but nothing works.

1 Answers

The required dependencies for scikit-survival,

  • cvxpy

  • cvxopt

  • joblib

  • numexpr

  • numpy 1.12 or later

  • osqp

  • pandas 0.21 or later

  • scikit-learn 0.22

  • scipy 1.0 or later

...will be automatically installed by pip when you run:

pip install scikit-survival

However, one module in particular, osqp, has CMake as one of its dependencies. If you don't have CMake installed, pip install scikit-survival will throw an error and the installation will fail.

You can download CMake for your OS at cmake.org/download

After CMake has installed, you should be able to successfully run

pip install scikit-survival

Notes:

  • GCC needs to be installed also
  • scikit-survival works with Python 3.5 or higher
  • More information is available in the docs
Related