Advertisement
Guest User

Untitled

a guest
Jun 16th, 2019
67
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 1.70 KB | None | 0 0
  1. ---------------------------------------------------------------------------
  2. AttributeError Traceback (most recent call last)
  3. <ipython-input-1-bcae5a697dad> in <module>
  4. ----> 1 import namespace_repro.module
  5.  
  6. ~/namespace-repro/src/namespace_repro/module/__init__.py in <module>
  7. ----> 1 from namespace_repro.module.x import x
  8.  
  9. ~/namespace-repro/src/namespace_repro/module/x.py in <module>
  10. ----> 1 import namespace_repro.module.y as y
  11. 2
  12. 3 x = y.y
  13.  
  14. AttributeError: module 'namespace_repro' has no attribute 'module'
  15. ---------------------------------------------------------------------------
  16.  
  17. In [1]: import namespace_repro.module.y as y # This doesn't work.
  18. ---------------------------------------------------------------------------
  19. AttributeError Traceback (most recent call last)
  20. <ipython-input-4-4035347ea59b> in <module>
  21. ----> 1 import namespace_repro.module.y as y
  22.  
  23. AttributeError: module 'namespace_repro' has no attribute 'module'
  24.  
  25. In [2]: import namespace_repro.module.y # But this one does! Why?
  26.  
  27. In [3]: dir(namespace_repro.module.y) # The error returns when we actually want to use the module.
  28. ---------------------------------------------------------------------------
  29. AttributeError Traceback (most recent call last)
  30. <ipython-input-3-d89bcfd9e509> in <module>
  31. ----> 1 dir(namespace_repro.module.y)
  32.  
  33. AttributeError: module 'namespace_repro' has no attribute 'module'
  34.  
  35. In [4]: from namespace_repro.module.y import y # This works fine!
  36.  
  37. In [5]: y
  38. Out[5]: True
  39.  
  40. . import-error-repro
  41. +-- setup.py
  42. +-- src
  43. | +-- namespace_repro
  44. | | +-- module
  45. | | | +-- __init__.py
  46. | | | +-- x.py
  47. | | | +-- y.py
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement