I have this script:
from astropy.io import fits
from astropy.utils.data import get_pkg_data_filename
fits_file = get_pkg_data_filename("../path_to_the_test_candidate/number_000150.fits")
fits.info(fits_file)
with fits.open(fits_file, 'update') as f:
for hdu in f:
hdu.header['OBJECT'] = "Mao"
fits.info(fits_file)
print(repr(fits.getheader(fits_file, 0)))
when copy-paste it in the shell line by line it works but when copy in a file and run python3 file.py this error appears: AssertionError: attempted to get a local data file outside of the __main__ tree. What is the problem?