Gammu in python error

Peter Otten __peter__ at
Sat Apr 2 12:27:46 EDT 2011

Santhosh Kumar wrote:

> Hi all,
>      I am new to gammu. I did the cofiguration with gammu very
>      successfully
> and if I try to send sms with command mode ( sudo echo "sms test from
> santhos pc probably yo vl call me" | /usr/bin/gammu --sendsms TEXT
> +919840411410 ) its working fine. So, I try to extend the code along with
> python so I installed python-gammu they I tried to import with python
>>>> import gammu
> Traceback (most recent call last):
>   File "<stdin>", line 1, in <module>
>   File "", line 3, in <module>
>     sm=gammu.StateMachine()
> AttributeError: 'module' object has no attribute 'StateMachine'
> This is the error which I am getting what should I do now does it required
> any patch for this error.

You have called your script "", so when you write

import gammu
sm = gammu.StateMachine()

inside that script it imports itself and, of course, doesn't find the 
StateMachine class. 

Rename your file to something that doesn't collide with modules you are 
using, don't forget to delete the compiled version gammu.pyc and  you should 
be OK.

More information about the Python-list mailing list