Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

'module' object is not callable #22

Closed
GRhOGS opened this issue Jan 2, 2019 · 12 comments
Closed

'module' object is not callable #22

GRhOGS opened this issue Jan 2, 2019 · 12 comments

Comments

@GRhOGS
Copy link

GRhOGS commented Jan 2, 2019

when I try to run the example code:

from mpu6050 import mpu6050
sensor = mpu6050(0x68)
print(sensor.get_accel_data())

It prints out an error on line 2 stating: 'module' object is not callable
I've installed it correctly, and there's no error when importing the module

@m-rtijn
Copy link
Owner

m-rtijn commented Jan 2, 2019

Hi @Georg2K2, thank you for using my library!

I have only been able to reproduce this issue by incorrectly importing the module.

>>> import mpu6050
>>> sensor = mpu6050(0x68)
Traceback (most recent call last):
  File "<stdin>", line 1, in <module>
TypeError: 'module' object is not callable

You can either import the module using from mpu6050 import mpu6050 and call the class constructor with mpu6050(0x68) or import the module using import mpu6050 and call the constructor with mpu6050.mpu6050(0x68).

I hope this fixes your issue.

@GRhOGS
Copy link
Author

GRhOGS commented Jan 3, 2019

Like stated above, I import the module like:
from mpu6050 import mpu6050
and use it like described by you, but it still doesnt work for me :c

@m-rtijn
Copy link
Owner

m-rtijn commented Jan 3, 2019

Hm. That is really weird. Does the example script (in the repository bin/mpu6050-example) work for you?

@GRhOGS
Copy link
Author

GRhOGS commented Jan 4, 2019

I get the error: No module named 'mpu6050'
I tried running the setup.py again, sadly it doesn't work. (also you might edit the instructions from "python setup.py install" to "sudo python setup.py install")
I tried doing the pip install, restarted and now I get "TypeError: 'module' object is not callable" on the example script

@m-rtijn
Copy link
Owner

m-rtijn commented Jan 4, 2019

Which version of python are you using? If your system has both python 2.7.x and python 3, are you consistently using the same python version while testing?

@GRhOGS
Copy link
Author

GRhOGS commented Jan 4, 2019

im using python python 3

@GRhOGS
Copy link
Author

GRhOGS commented Jan 4, 2019

but I got it working now on Python 2.7.13!

@m-rtijn
Copy link
Owner

m-rtijn commented Jan 5, 2019

Nice that it works now, could you maybe explain what you did differently with python 2.7? In the case that someone else might ever stumble on the same issue as you.

@m-rtijn m-rtijn closed this as completed Jan 5, 2019
@GRhOGS
Copy link
Author

GRhOGS commented Jan 5, 2019

I just launched the script with python 2 instead of 3... ¯_(ツ)_/¯

@tmubashshira
Copy link

I just launched the script with python 2 instead of 3... ¯_(ツ)_/¯

can you please tell the command you used to launch python 2 in raspberry pi??? I'm having the same error.....

@tmubashshira
Copy link

I just launched the script with python 2 instead of 3... ¯_(ツ)_/¯

if you're using python 2, doesn't it create problem in other operations???

@GRhOGS
Copy link
Author

GRhOGS commented Apr 4, 2021

I didn't run into any other problems... I haven't used that pi in years, I would have to google it again as well, sorry :/ maybe something like 'python2.7' in cmd, I'm not a huge Ubuntu buff...

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

3 participants