Python ImportError - 正确导入文件但导入包含函数时出错

时间:2015-07-16 00:44:40

标签: python python-import

我的ImportErrorImportError: cannot import name filter_name 仅使用此行FilterTest.py执行from Filter2D import filter_name 我可以轻松地从其他.py文件导入函数,但使用filter_nameFilterTest.py函数的相同路径,我收到此错误。我只能找到与循环导入相关的ImportErrors问题,我无法将其减少到它。我做错了什么?

try2/
        - asian.py
            - toAsian()

        - europe.py
            - man2euro()
            - euro2asian()

        - Filter2D.py
            -- from FilterMain import filter
            - filter_name() -> filter()

        - FilterMain.py
            -- from asian import toAsian
            -- from europe import euro2asian
            - filter() -> toAsian(), euro2asian()

        - FilterTest.py
            #-- from asian import toAsian       # works well
            #-- from europe import euro2asian   # works well
            #-- import Filter2D                 # works well
            -- from Filter2D import filter_name # ImportError: cannot import name filter_name

0 个答案:

没有答案