SHARE
TWEET

Untitled

a guest Mar 20th, 2019 60 Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1. testtest.py
  2. testmodulesbase.py
  3. testmodulesblah.py
  4.      
  5. File "modules/blah.py", line 1, in <module>
  6.     from .base import BaseModule
  7. ImportError: attempted relative import with no known parent package
  8.      
  9. #!/usr/bin/env python
  10. import importlib
  11. class Test():
  12.     def __init__(self):
  13.         spec = importlib.util.spec_from_file_location("blah", "modules/blah.py")
  14.         mod = importlib.util.module_from_spec(spec)
  15.         spec.loader.exec_module(mod)
  16. def main():
  17.     t = Test()
  18. if __name__ == '__main__':
  19.     main()
  20.      
  21. class BaseModule():
  22.     modulename = "base"
  23.     def __init__(self,name):
  24.         print("Initializing module %s" % (self.modulename))
  25.      
  26. from .base import BaseModule
  27. class BlahModule(BaseModule):
  28.     modulename = "blah"
RAW Paste Data
We use cookies for various purposes including analytics. By continuing to use Pastebin, you agree to our use of cookies as described in the Cookies Policy. OK, I Understand
Not a member of Pastebin yet?
Sign Up, it unlocks many cool features!
 
Top