question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

import deepreg error: module 'deepreg' has no attribute 'model'

See original GitHub issue

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.

Issue Analytics

  • State:closed
  • Created 3 years ago
  • Reactions:1
  • Comments:16 (16 by maintainers)

github_iconTop GitHub Comments

1reaction
zacbaumcommented, Feb 5, 2021

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

1reaction
zacbaumcommented, Feb 2, 2021

Regarding this error, can you at least try on py3.7 LOL… it’s just a random guess if py version can be the reason.

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.

Read more comments on GitHub >

github_iconTop Results From Across the Web

DeepReg - Read the Docs
DeepReg is a freely available, community-supported open-source toolkit for research and education in medical image.
Read more >
AttributeError: 'module' object has no attribute 'model'
This error occurs in the definition of the Poll class: class Poll(models.model):. Either the class model is misspelled in the definition of the ......
Read more >
deepreg - PyPI
DeepReg is a freely available, community-supported open-source toolkit for research and education in medical image registration using deep learning.
Read more >
Network architectures — MONAI 1.1.0 Documentation
Residual module with multiple convolutions and a residual connection. For example: from monai.networks.blocks import ResidualUnit convs = ResidualUnit( ...
Read more >
How to Resolve Module Has No Attribute - Python Error ...
In this tutorial I will be showing you how to MANAGE THE " MODULE HAS NO ATTRIBUTE " ERROR MESSAGE using Python. This...
Read more >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found