TypeError: 'module' object is not callable

前端 未结 11 1908
耶瑟儿~
耶瑟儿~ 2020-11-22 12:06
File \"C:\\Users\\Administrator\\Documents\\Mibot\\oops\\blinkserv.py\", line 82, in __init__
    self.serv = socket(AF_INET,SOCK_STREAM)
TypeError: \'module\' objec         


        
11条回答
  •  广开言路
    2020-11-22 12:20

    Here is another gotcha, that took me awhile to see even after reading these posts. I was setting up a script to call my python bin scripts. I was getting the module not callable too.

    My zig was that I was doing the following:

    from mypackage.bin import myscript
    ...
    myscript(...)
    

    when my zag needed to do the following:

    from mypackage.bin.myscript import myscript
    ...
    myscript(...)
    

    In summary, double check your package and module nesting.

    What I am trying to do is have a scripts directory that does not have the *.py extension, and still have the 'bin' modules to be in mypackage/bin and these have my *.py extension. I am new to packaging, and trying to follow the standards as I am interpreting them. So, I have at the setup root:

    setup.py
    scripts/
          script1
    mypackage/
       bin/
          script1.py
       subpackage1/
       subpackage_etc/
    

    If this is not compliant with standard, please let me know.

提交回复
热议问题