Dynamic class loading in Python 2.6: RuntimeWarning: Parent module 'plugins' not found while handling absolute import

前端 未结 5 2093
不知归路
不知归路 2020-12-30 23:37

I am working on a plugin system where plugin modules are loaded like this:

def load_plugins():
   plugins=glob.glob(\"plugins/*.py\")
   instances=[]
   for         


        
5条回答
  •  天命终不由人
    2020-12-31 00:09

    You can try adding below statement at the beginning of import statements.

    from __future__ import absolute_import
    

提交回复
热议问题