Python 从嵌套目录/filename.py导入函数

Python 从嵌套目录/filename.py导入函数,python,import,Python,Import,我有以下目录结构: V1.0/ module/ answer_type/ __init__.py worker.py src/ __init__.py ans_type/ __init__.py

我有以下目录结构:

V1.0/
    module/
          answer_type/
                 __init__.py
                 worker.py
                 src/
                      __init__.py  
                      ans_type/
                           __init__.py
                           sent_process.py
          module_two/
          module_three/
我已经将_init__u;.py文件放在目录中,以便可以导入它。但它仍然不允许从最内部的文件导入类

sent_process.py看起来像

from light_lizer.result_initiator import ResultInitiator
import re
import sys
import gearman
import sys,json

class QueryPylinkAnsTypeDetector(GearManOverride):
    def __init__(self, config):
        super(QueryAnsTypeDetector, self).__init__(config)
        self.init_log()

    def init_log(self):
        print "__init_log"
        self.abs_path = os.path.abspath(__file__).replace(os.getcwd(),'').replace('/','-').replace('.py','').replace('.','_')
        self.log_set_obj = LogSetting(type(self).__name__)
        self.logger = self.log_set_obj.logger

    def preProcessLink(self, link):
    new_link = link[-2:]
        return new_link


    def processSentenceSingle(self, read_str):
        post_script_link_list = []
    linkage[0] = 'xyz'
    post_script_link_list = self.preProcessLink(linkage[0])
        return result
在worker.py中,我试图从sent_process.py导入函数

给出错误:从src.answer\u type.pylink\u进程导入QueryPylinkAnsTypeDetector ImportError:没有名为src.ans\u type.sent\u进程的模块

有人能告诉我这里出了什么问题吗

更新:

在V1.0目录中,我以以下方式执行worker:

python - m module/answer_type/worker

您在/ans\u type中没有uu init\uuuu.py…@jornsharpe:updated,在/ans\u type dir中添加了init文件并进行了测试,但仍然存在相同的错误您的结构看起来是合法的,这意味着您可能缺少某些文件权限、执行路径。。。。当您调用:python worker.py时,您是否有相同的错误,还是仅当您将模块导入其他位置时才有相同的错误?@samyarus:permission我检查过了,没有问题。仅当以这种方式导入时,我对worker.py有问题。没有别的地方能告诉我们你们的进口链是什么?我能看见那个工人
python - m module/answer_type/worker