Python Forum

Full Version: 'int' object is not callable
You're currently viewing a stripped down version of our content. View the full version with proper formatting.
When testing an example Python program I get 'int' object is not callable


import time
import board
import Adafruit_DHT
 
# Initial the dht device, with data pin connected to:
# dhtDevice = adafruit_dht.DHT22(board.D4)
 
# you can pass DHT22 use_pulseio=False if you wouldn't like to use pulseio.
# This may be necessary on a Linux single board computer like the Raspberry Pi,
# but it will not work in CircuitPython.
dhtDevice = Adafruit_DHT.DHT11(board.D4, use_pulseio=False)
 
while True:
    try:
        # Print the values to the serial port
        temperature_c = dhtDevice.temperature
        temperature_f = temperature_c * (9 / 5) + 32
        humidity = dhtDevice.humidity
        print(
            "Temp: {:.1f} F / {:.1f} C    Humidity: {}% ".format(
                temperature_f, temperature_c, humidity
            )
        )
 
    except RuntimeError as error:
        # Errors happen fairly often, DHT's are hard to read, just keep going
        print(error.args[0])
        time.sleep(2.0)
        continue
    except Exception as error:
        dhtDevice.exit()
        raise error
 
    time.sleep(2.0)
Error:
>>> %Run DHT11_test.py Traceback (most recent call last): File "/home/pi/Python/Progs/DHT11_test.py", line 11, in <module> dhtDevice = Adafruit_DHT.DHT11(board.D4, use_pulseio=False) TypeError: 'int' object is not callable >>>
Are you using CircuitPython or something else?

It looks like you've installed the library "Adafruit_DHT", which is marked deprecated.
The new library (which appears to match your example in use) is "Adafruit_CircuitPython_DHT".

https://learn.adafruit.com/dht-humidity-...thon-setup tells how to install the correct library.
I read that the Adafruit_DHT library has been deprecated and that you should be using the adafruit-circuitpython-dht library instead. Isn't it the cause of this issue?
Look for some missing brackets.
I installed Adafruit_CircuitPython_DHT successfully. If I go into Synaptic Package Manager I can't find it there. Why can't I find it in there? Where do I see software which is deprecated?
The code goes thru now but I got 'DHT sensor not found'. It's the three wire DHT11 and I have tested two different wirings and tried 5V. I keep searching.
hcccs Wrote:If I go into Synaptic Package Manager I can't find it there. Why can't I find it in there?
The Synaptic Package Manager shows only the packages that are included in your linux distribution.

Many Python modules can be found in the Python Package Index and they are installed with the pip command.

Some of these Python modules are included in the linux distribution and many are not.