Python Forum
'int' object is not callable
Thread Rating:
  • 0 Vote(s) - 0 Average
  • 1
  • 2
  • 3
  • 4
  • 5
'int' object is not callable
#1
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 >>>
Reply
#2
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.
Reply
#3
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?
Reply
#4
Look for some missing brackets.
Reply
#5
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.
Reply
#6
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.
Reply


Possibly Related Threads…
Thread Author Replies Views Last Post
  error in class: TypeError: 'str' object is not callable akbarza 2 444 Dec-30-2023, 04:35 PM
Last Post: deanhystad
  TypeError: 'NoneType' object is not callable akbarza 4 916 Aug-24-2023, 05:14 PM
Last Post: snippsat
  [NEW CODER] TypeError: Object is not callable iwantyoursec 5 1,260 Aug-23-2023, 06:21 PM
Last Post: deanhystad
  Need help with 'str' object is not callable error. Fare 4 775 Jul-23-2023, 02:25 PM
Last Post: Fare
  TypeError: 'float' object is not callable #1 isdito2001 1 1,044 Jan-21-2023, 12:43 AM
Last Post: Yoriz
  'SSHClient' object is not callable 3lnyn0 1 1,125 Dec-15-2022, 03:40 AM
Last Post: deanhystad
  TypeError: 'float' object is not callable TimofeyKolpakov 3 1,367 Dec-04-2022, 04:58 PM
Last Post: TimofeyKolpakov
  API Post issue "TypeError: 'str' object is not callable" makeeley 2 1,832 Oct-30-2022, 12:53 PM
Last Post: makeeley
  Merge htm files with shutil library (TypeError: 'module' object is not callable) Melcu54 5 1,492 Aug-28-2022, 07:11 AM
Last Post: Melcu54
  [split] TypeError: 'int' object is not callable flash77 4 2,676 Mar-21-2022, 09:44 PM
Last Post: deanhystad

Forum Jump:

User Panel Messages

Announcements
Announcement #1 8/1/2020
Announcement #2 8/2/2020
Announcement #3 8/6/2020