How to fix AttributeError: module ‘scipy’ has no attribute ‘constants’

Problem:

While trying to run your Python project, you see an error message like

AttributeError: module 'scipy' has no attribute 'constants'

even though have have already imported scipy:

import scipy

Solution:

You need to explicitly import scipy.constants

import scipy.constants

I generally recommend to import both scipy and scipy.constants in case you use scipy itself elsewhere in your code:

import scipy
import scipy.constants