1

I am using a fully updated installation of Manjaro (as of 15/08/2020). Using python 3.8.3 for this project.

I would like to use the python module netifaces to determine the IP address of one of my network interfaces. I have tried installing the module both through pip (sudo pip install netifaces) and pacman (sudo pacman -S python-netifaces). Both give me netifaces version 0.10.9. However, when I run

import netifaces
interfaces = netifaces.interfaces()
print(interfaces)

I get the following error message:

---------------------------------------------------------------------------
AttributeError                            Traceback (most recent call last)
<ipython-input-1-e0d29647271f> in <module>
      1 import netifaces
----> 2 interfaces = netifaces.interfaces()

AttributeError: module 'netifaces' has no attribute 'interfaces'

When I then check dir(netifaces) I get

['__builtins__',
 '__cached__',
 '__doc__',
 '__file__',
 '__loader__',
 '__name__',
 '__package__',
 '__spec__']

It however does work fine with python 2.7.18, where it returns a list of my network interfaces as expected.

It also works perfectly on my openSUSE Leap 15.1 installation. This uses python 3.6.10 and netifaces 0.10.9.

I don't seem to be able to find any similar problems let alone their solutions when searching. Any help would be greatly appreciated.

tmata
  • 11
  • 1
  • 2
    Have you got a file of your own named "netifaces.py"? (try `print(netifaces.__file__)` after importing it.) – snakecharmerb Aug 15 '20 at 09:27
  • There is no file named netifaces.py in the directory. `print(netifaces.__file__)` returns `/home/[USER]/.cache/Python-Eggs/netifaces-0.10.9-py3.8-linux-x86_64.egg-tmp/netifaces.cpython-38-x86_64-linux-gnu.so`. This does however seems like an odd location for a python package, if I remove ~/.cache/Python-Eggs it does not change the file location. – tmata Aug 16 '20 at 10:08

0 Answers0