In LungCTAnalyzer 2.49 in Slicer 5.0.2 in macOS 12.4 with Python 3.9.10, when generating PDF report: report is generated in LungCTAnalyzerReports but Python Interactor shows
modules/LungCTAnalyzer.py", line 843, in onCreatePDFReportButton
AttributeError: module 'os' has no attribute 'startfile'
Seems os.startfile is Windows-specific, and macOS may need
The error is not seen with Create CSV file (after PDF report generation).
Yes, that call is windows specific. It would be great if someone could contribute a fix to generalize the code.
Thank you @pieper .
I think this fixed the problem.
@ashipde could you
in the extension manager tomorrow or the day after that, then update the Lung CT Analyzer and test again? I have no MAC or Linux available …
@rbumm Thank you for the quick-fix. The error does not appear, but on macOS, the generated PDF report is not opened automatically, which I believe is the intent. In error messages I see: The file
/\Users\ashipde\Documents\LungCTAnalyzerReports\[redacted].pdf does not exist. But the file exists… seems backslashes are the issue (macOS/Unix using forward ones unlike Windows).
Thank you. I removed the backslash generation in the PDF path for macOS and Linux.
Could you test again?
The file-missing error is gone after the latest fix. Interactor window shows
Starting '/Users/ashipde/Documents/LungCTAnalyzerReports/[redacted].pdf' .... However, the PDF file does not auto-open. My system Python opens the file in PDF viewer app with
subprocess.call(['open', '/Users/ashipde/Documents/LungCTAnalyzerReports/[redacted].pdf']), so not sure what may be the issue.
@ashipde please try if the same subprocess call opens the file in Slicer’s Python interactor. If it does not work then you may need to use the startup environment.
My mistake. The report file does auto-open as expected with the latest GitHub download of the extension. May be my extension uninstall/re-install was not done properly by me.