How to Solve NameError: name 'fits' is not defined -- astropy

Solution: Import the 'fits' module

# Add the following line to the top of your code
from astropy.io import fits

 

For more information:
astropy fits