I want determine the ip of my router address by writing a python code. I found this proposal:
$ sudo easy_install netifaces
Python 2.6.5 (r265:79063, Oct 1 2012, 22:04:36)
...
$ ipython
...
In [8]: import netifaces
In [9]: gws=netifaces.gateways()
In [10]: gws
Out[10]:
{2: [('192.168.0.254', 'eth0', True)],
'default': {2: ('192.168.0.254', 'eth0')}}
In [11]: gws['default'][netifaces.AF_INET][0]
Out[11]: '192.168.0.254'
and my result in the terminal:
In [1]: import netifaces
In [2]: gws=netifaces.gateways()
---------------------------------------------------------------------------
AttributeError Traceback (most recent call last)
/home/rimeh/Bureau/<ipython-input-2-47b29e25a9b8> in <module>()
----> 1 gws=netifaces.gateways()
AttributeError: 'module' object has no attribute 'gateways'
How can help me please, I need help. thanks.