I solved the problem by downgrading joblib to version 1.3.0. It was mentioned in the documentation of scikit-learn that this version is the minimum requirement. It seems that Memory was removed from the recent version.