TypeError: 'module' object is not callable


#1

Hi,

Hi i am trying out your project Twitter Feed Sensor but i encountered a problem when running the wifi_twit.py

Error:
File "wifi_twit.py, line 22, in <module>
api = twitter.api (consumer_key=…)
TypeError: ‘module’ object is not callable

I hope you can guide me in solving the error.

Thank You


#2

Hi,

I have already pip install twitter like you suggested however now i encounter another problem.

root@GroveNoise:~/GrovePi/Projects/Sensor Twitter Feed# python wifi_twit.py
Traceback (most recent call last):
File “wifi_twit.py”, line 12, in <module>
import grovepi
File “/usr/local/lib/python2.7/dist-packages/grovepi-0.0.0-py2.7.egg/grovepi.py”, line 24, in <module>
bus = smbus.SMBus(0)
IOError: [Errno 2] No such file or directory

I have done apt-get update and upgrade.

Another issue that i faced was with the firmware update, i tried once it was fine but the second time it was giving me error such asroot@GroveNoise:~/GrovePi/Firmware# ./firmware_update.sh
Updating the GrovePi firmware

Do you want to update the firmware? [y,n]y
Make sure that GrovePi is connected to Raspberry Pi./firmware_update.sh: line 12: [: ./grove_pi_firmware.hex: unary operator expected

Firmware not found
Check if firmware is there or run again
Press any key to exit

Please help guide me in solving this issue


#3

Hey,
For the IO error, update bus = smbus.SMBus(0) on line 24 to bus = smbus.SMBus(1). This should allow the Pi to access the I2C lines on the latest revision of the Pi.

Now for the firmware error, make sure that you have the latest version of the GrovePi Github repository and run the script as root sudo # ./firmware_update.sh.

-Karan


#4

Hey,

The same error is ‘module’ object has no attribute ‘Api’ but after the I change it to ‘api’ same error appear ‘module’ object not callable. I have install twitter and install twitter library, firmware is updated but still same issue appear. You can refer to the attachment.

Another question, i tried to run the project without uploading it to twitter, it works fine but i am not able to quit the python script i tried to add in codes such as ‘except KeyboardInterrupt’ but it still i am unable to quit the script.

Please help me, thank you


#5

Hey,
Can you check out the example here: https://github.com/bear/python-twitter/blob/master/examples/tweet.py and try that out.
As for stopping the program, you can use “Ctrl+Z” to stop it .

-Karan


#6

Hi,

“For the IO error, update bus = smbus.SMBus(0) on line 24 to bus = smbus.SMBus(1). This should allow the Pi to access the I2C lines on the latest revision of the Pi.”

I could not find that line. when i go into the python file (wifi-twit.py) there is nothing on line 24. Where exactly should i go to make the necessary changes. if you dont mind can you please explain to me how this error occur? before this the python script runs normally, i did not modify anything else i also did not shutdown the system but the next time i tried to run this error appear.


#7

Hey,
I am not exactly sure what changed on your system but what this error says is that you are trying to use the wrong I2C bus. The Raspberry Pi has 2 I2C buses, and we are using I2C bus 1.

First try running setup.py in the Software/Python folder: sudo python setup.py install. That would reinstall the library.

Try that out and if that does not work out, we’ll help you edit it.

-Karan