DeepReg: import deepreg error: module 'deepreg' has no attribute 'model'
Subject of the issue
Unable to import deepreg into other python applications, using the 0.1.2 release.
>> import deepreg
Traceback (most recent call last):
File "<console>", line 1, in <module>
File "C:\Users\zac_b\AppData\Local\NA-MIC\Slicer 4.13.0-2021-01-05\lib\Python\Lib\site-packages\deepreg\__init__.py", line 2, in <module>
import deepreg.dataset
File "C:\Users\zac_b\AppData\Local\NA-MIC\Slicer 4.13.0-2021-01-05\lib\Python\Lib\site-packages\deepreg\dataset\__init__.py", line 2, in <module>
import deepreg.dataset.loader
File "C:\Users\zac_b\AppData\Local\NA-MIC\Slicer 4.13.0-2021-01-05\lib\Python\Lib\site-packages\deepreg\dataset\loader\__init__.py", line 2, in <module>
from deepreg.dataset.loader.grouped_loader import GroupedDataLoader
File "C:\Users\zac_b\AppData\Local\NA-MIC\Slicer 4.13.0-2021-01-05\lib\Python\Lib\site-packages\deepreg\dataset\loader\grouped_loader.py", line 11, in <module>
from deepreg.dataset.loader.interface import (
File "C:\Users\zac_b\AppData\Local\NA-MIC\Slicer 4.13.0-2021-01-05\lib\Python\Lib\site-packages\deepreg\dataset\loader\interface.py", line 12, in <module>
from deepreg.dataset.preprocess import resize_inputs
File "C:\Users\zac_b\AppData\Local\NA-MIC\Slicer 4.13.0-2021-01-05\lib\Python\Lib\site-packages\deepreg\dataset\preprocess.py", line 11, in <module>
from deepreg.model.layer_util import (
File "C:\Users\zac_b\AppData\Local\NA-MIC\Slicer 4.13.0-2021-01-05\lib\Python\Lib\site-packages\deepreg\model\__init__.py", line 2, in <module>
import deepreg.model.backbone
File "C:\Users\zac_b\AppData\Local\NA-MIC\Slicer 4.13.0-2021-01-05\lib\Python\Lib\site-packages\deepreg\model\backbone\__init__.py", line 2, in <module>
from deepreg.model.backbone.global_net import GlobalNet
File "C:\Users\zac_b\AppData\Local\NA-MIC\Slicer 4.13.0-2021-01-05\lib\Python\Lib\site-packages\deepreg\model\backbone\global_net.py", line 8, in <module>
from deepreg.model import layer, layer_util
File "C:\Users\zac_b\AppData\Local\NA-MIC\Slicer 4.13.0-2021-01-05\lib\Python\Lib\site-packages\deepreg\model\layer.py", line 6, in <module>
import deepreg.model.layer_util as layer_util
AttributeError: module 'deepreg' has no attribute 'model'
I suspect this has to do with the fact that layer_util is a module and not an attribute, which is why the import deepreg.model.layer_util as layer_util
error is thrown.
This should be able to be resolved by replacing that code with from deepreg.model import layer_util
.
If the bug is confirmed, would you be willing to submit a PR? (Help can be provided if you need assistance submitting a PR)
Yes
Your environment
- DeepReg version 0.1.2
- Windows 10
- Python Version 3.6.7
Steps to reproduce
See above; call import deepreg
.
Expected behaviour
deepreg should import, and then allow the user to make calls from within the API.
Actual behaviour
See above.
About this issue
- Original URL
- State: closed
- Created 3 years ago
- Reactions: 1
- Comments: 16 (16 by maintainers)
Commits related to this issue
- Issue #661: fix import error — committed to DeepRegNet/DeepReg by mathpluscode 3 years ago
Without a change to the code, things can’t be solved - I’d rather find a fix that didn’t involve users needing to edit code manually
Can’t use any python other than 3.6.7 - That’s what’s built-in to 3D Slicer in the latest versions. It may increase in the future, but that’s not something we can bank on.
Yes - no problem for me on Linux either; just a windows issue. But we need to try and find something if we want to be able to make the slicer extension work 😃