0
我有功能:为什么我得到的消息:“模块”对象有没有属性“load_source”
def load_from_file(filepath, expected_class):
mod_name, file_ext = os.path.splitext(os.path.split(filepath)[-1])
py_mod = imp.load_source(mod_name, filepath)
在templatetags文件
,它是确定的。
但是,当我复制/粘贴此功能,我认为我得到错误:
'module' object has no attribute 'load_source'
我的例子观点:
import os, imp
def get_module(request, position):
[...]
imod = load_from_file(settings.PROJECT_ROOT + '/core/manager/modules/' + mod.type.fileview + '.py', 'ModuleManager')
[...]
def load_from_file(filepath, expected_class):
[...]
为什么这不工作?
在两个模块中打印imp(在调用函数之前)并查看是否有不同的东西 –
是的,我有我自己的模块名为imp – Nips