DCBIA-OrthoLab / SlicerAutomatedDentalTools

A 3D Slicer extension to use AMASSS, ALI-CBCT and ALI-IOS
Other
81 stars 24 forks source link

No module named 'logic' #8

Open jamesobutler opened 2 years ago

jamesobutler commented 2 years ago

Is this leftover example code or are you actually trying to utilize this logic package from PyPI? I'm observing when running the CLIs No module named 'logic'.

https://github.com/DCBIA-OrthoLab/SlicerAutomatedDentalTools/blob/5c13f996e1f367e131b2c2279c9b345652e3086f/ALI_CBCT/ALI_CBCT.py#L40 https://github.com/DCBIA-OrthoLab/SlicerAutomatedDentalTools/blob/5c13f996e1f367e131b2c2279c9b345652e3086f/ALI_IOS/ALI_IOS.py#L39 https://github.com/DCBIA-OrthoLab/SlicerAutomatedDentalTools/blob/5c13f996e1f367e131b2c2279c9b345652e3086f/AMASSS_CLI/AMASSS_CLI.py#L42

Maxlo24 commented 2 years ago

I don't know how to fix it, one Librairie is using logic. When the module was tested on MAC the code crashed with No module named 'logic' error. I had to run this line to remove the error https://github.com/DCBIA-OrthoLab/SlicerAutomatedDentalTools/blob/5c13f996e1f367e131b2c2279c9b345652e3086f/ALI_CBCT/ALI_CBCT.py#L40

Maybe there is a better solution you're aware of. Thanks

jamesobutler commented 2 years ago

The "No module named 'logic'" is an issue with trying to import Slicer infrastructure stuff from within PythonSlicer.exe which is what runs the CLI script.

PS C:\Users\JamesButler\AppData\Local\NA-MIC\Slicer 5.0.3\bin> ./PythonSlicer.exe
Python 3.9.10 (main, Jul  8 2022, 02:32:50) [MSC v.1930 64 bit (AMD64)] on win32
Type "help", "copyright", "credits" or "license" for more information.
>>> import slicer.util
No module named 'logic'

https://discourse.slicer.org/t/how-to-import-slicer-in-python-cli/8083/3?u=jamesobutler

Generally, CLIs are not intended to have direct access to the Slicer scene / infrastructure. They are meant for non-interactive data processing with non-slicer libraries. If you want to work within the Slicer environment, you should keep the code within a python scripted module.

I've generally not seen the attempted pip_install of packages from a python scripted Slicer CLI like below. https://github.com/DCBIA-OrthoLab/SlicerAutomatedDentalTools/blob/6928dddbbf69757a3300c56e54966cd1f85ae488/ALI_CBCT/ALI_CBCT.py#L61-L65

Typically a Slicer scripted loadable module will either:

luciacev commented 9 months ago

Thank you for your input. The module runs properly despite this error message that @Jeanneclre is working to address.