importlib-metadata package not found for PIL (Pillow)

97 Views Asked by At

The little program below is almost a copy-paste for an example form Astropy website. The program works fine under PyCharm environment but when trying to make it executable using PyInstaller, I'm getting an error while running the program.

import matplotlib.pyplot as plt
from astropy.visualization import ImageNormalize, ZScaleInterval, LinearStretch
from importlib_metadata import metadata
from astropy.wcs import WCS
from astropy.io import fits


reference_image = "C:/Users/Michel/Documents/Astrophotography/MCD Images/SN_Pipeline_Reference/A8 Reference.fits"
science_image = "C:/Users/Michel/Documents/Astrophotography/MCD Images/SN_Pipeline_Science/A8/A8_Registered1.fit"
plots_path = "C:/Users/Michel/Documents/Astrophotography/MCD Images/SN_Pipeline_Science/A8/"
hdu = fits.open(reference_image)[0]
hdu1 = fits.open(science_image)[0]
wcs = WCS(hdu.header)
norm = ImageNormalize(hdu.data, interval=ZScaleInterval(), stretch=LinearStretch())
plt.subplot(projection=wcs)
plt.imshow(hdu1.data, cmap='gray', norm=norm, interpolation='none')
plt.grid(color='white', ls='solid')
plt.xlabel('Galactic Longitude')
plt.ylabel('Galactic Latitude')
plt.show()`

The error is: Importlib.metadata.PackageNotFoundError: No package metadata was found for PIL

Since, the program call two libraries, I upgrade astropy (version 5.3.4) and matplotlib (version 3.8.1). Furthermore, I upgrade Pillow to version 10.1.0 and importlib-metadata (version 6.8.0). Even with those upgrade, I'm still getting the same error messages while running the executable file.

I check over the internet but could not find something to fix this issue.

Any help will be appreciated...

0

There are 0 best solutions below