简体   繁体   中英

TypeError: 'module' object is not callable in python

I have found many articles related to this post but I no solution provided works in my case.

i have create a file called Thelephony_Test.py and inside, I have:

import Preconfig

m_device_cfg = Preconfig.Device_Config(..parameters...)

The Preconfig class is defined in the file Preconfig.py as done below

import Devices

class Device_Config(Devices):
    def __init___(self, ...parameters...):
        Devices.__init___(...parameters...)

The Devices class is defined in Devices.py as below:

class Devices(object):
    def __init__(self, ...parameters...):
         self._xxx = parameter1
         self._yyy = parameter2

i'm still facing the error below:

 File "C:\Users\scayetanot\workspace\AutomationTests\TestScripts\Telephony_Test.py", line 40, in <module>
    m_device_cfg = Preconfig.Device_Config(m_device_adb_id, monkey_mdevice, easymonkey_mdevice, mhierarchyviewer, "M_TEL", mdevicetype)
TypeError: 'module' object is not callable

I have tried to change the import of the call from import to from ... import ...

but I still have the issue. Any idea ?

Thanks a lot

The statement

import Devices

creates a reference to a module called Devices in Preconfig.py . You can't inherit from a module as you attempt to do in

class Device_Config(Devices):

You need to inherit from the class Devices in the module of the same name with

class Device_Config(Devices.Devices):

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM