AstarVienna/ScopeSim

sim.bug_report() failing

Closed this issue · 4 comments

This is my first METIS bug report. For information, I am running ScopeSim v0.8.4 and ScopeSim_templates v0.5.4 using the 'PyCharm' IDE. I have a python script (starting fragment below) which runs end-to-end to generate a METIS IFU spectral images. However, if I insert a call to sim.bug_report() at the start it crashes,

#!/usr/bin/env python
import numpy as np
import scopesim as sim
import scopesim_templates as sim_tp
from matplotlib import pyplot as plt
import pyckles
from astropy.io.fits import BinTableHDU
from astropy import units as u
from synphot import models, SourceSpectrum, Empirical1D

sim.bug_report()

output

C:\Users\hkn21281\AppData\Local\Programs\Python\Python311\python.exe D:\Users\hkn21281\PycharmProjects\metsim\source\metsim.py 
Python:
3.11.1 (tags/v3.11.1:a7a450f, Dec  6 2022, 19:58:39) [MSC v.1934 64 bit (AMD64)]

Installed Python packages:
Traceback (most recent call last):
  File "D:\Users\hkn21281\PycharmProjects\metsim\source\metsim.py", line 11, in <module>
    sim.bug_report()
  File "C:\Users\hkn21281\AppData\Local\Programs\Python\Python311\Lib\site-packages\scopesim\utils.py", line 200, in bug_report
    _write_bug_report(sys.stdout)
  File "C:\Users\hkn21281\AppData\Local\Programs\Python\Python311\Lib\site-packages\scopesim\utils.py", line 168, in _write_bug_report
    packages = set(_get_required_packages())
               ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "C:\Users\hkn21281\AppData\Local\Programs\Python\Python311\Lib\site-packages\scopesim\utils.py", line 139, in _get_required_packages
    for req in reqs:
TypeError: 'NoneType' object is not iterable

END Glasse 5/11/24

Thanks @AGlasse. Ironic that the bug reporting feature contains a bug...

(I've taken the liberty to replace your dashed lines with three backticks. Github uses markdown, and a dashed line means that the line above it is a header, while text enclosed between lines with three backticks means something like verbatim in latex.)

It should be easy to add a fail safe for this error, but I don't really understand what is going on. It looks like there is something weird with your installation.

Is there a directory "C:\Users\hkn21281\AppData\Local\Programs\Python\Python311\Lib\site-packages\scopesim-0.8.4.dist-info" on your system (or similar perhaps)? And does that have a file "METADATA" in it? If so, could you please share the contents of that file?

Thanks for sharing the file. The files looks all normal, but it seems that for some reason it cannot be found by importlib.metadata. (I tried to reformat the comment, but apparently failed.)

I've added a workaround for the bug in #492, so that at least bug_report() wouldn't crash, but there is still something weird going on. The fix should make it to ScopeSim v0.9.0 I expect, which we plan to release soon.

I suggest to try things with a fresh installation, especially if you face more of such problems. For example, you are still using Python 3.11.1, while 3.11.10 is the latest.