How to fix AttributeError: module 'scipy' has no attribute 'constants'
Problem:
While trying to run your Python project, you see an error message like
scipy_attribute_error.txt
AttributeError: module 'scipy' has no attribute 'constants'
even though have have already imported scipy
:
repro_import_scipy.py
import scipy
Solution
You need to explicitly import scipy.constants
fix_imports.py
import scipy.constants
I generally recommend to import both scipy and scipy.constants in case you use scipy
itself elsewhere in your code:
recommended_imports.py
import scipy
import scipy.constants
Check out similar posts by category:
Python
If this post helped you, please consider buying me a coffee or donating via PayPal to support research & publishing of new posts on TechOverflow