In scipy 1.7 i have the following error: ImportError: cannot import name 'factorial' from 'scipy.misc' The factorial function in scipy onwards is located in scipy.special Changing the from scipy.misc import factorial to from scipy.special import factorial solve the error