Coding/Python

'module' object is not callable 파이썬

YOY^0^ 2020. 12. 14. 05:07

'module' object is not callable

모듈 객체를 불러올 수 없다.

 

문제점

from tr2

class Main():
    def __init__(self):
        super().__init__()

        tr2()

오류코드: 'module' object is not callable

 

개선 후

from tr2 import tr2

class Main():
    def __init__(self):
        super().__init__()

        tr2()

if __name__ == "__main__":
    Main()

tr2이라는 클래스를 부를 목적으로 무심코 from만햇더니 모듈을 불러와지게됨 -> import를 붙여주니 해결

 

참고: devday.tistory.com/entry/TypeError-module-object-is-not-callable