简体   繁体   English

TypeError:“模块”对象在python中不可调用

[英]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: 我创建了一个名为Thelephony_Test.py的文件,里面有:

import Preconfig

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

The Preconfig class is defined in the file Preconfig.py as done below Preconfig类在文件Preconfig.py中定义,如下所示

import Devices

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

The Devices class is defined in Devices.py as below: Devices类在Devices.py中定义如下:

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 ... 我试图将呼叫的导入从import更改为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 . Preconfig.py创建对称为Devices模块的引用。 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 您需要从具有相同名称的模块中的Devices 继承,

class Device_Config(Devices.Devices):

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

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