user3475575
user3475575

Reputation: 53

Python :: AttributeError: 'module' object has no attribute 'interfaces'

I downloaded a python project from github:

to work with interface file of ubuntu. the problem is when I try to use the module as the Readme said I get this:

Traceback (most recent call last):
  File "./ss.py", line 7, in <module>
    adapters = debinterface.interfaces()
AttributeError: 'module' object has no attribute 'interfaces'

my ss.py script is:

#!/usr/bin/python

import debinterface
import sys
sys.path.append("/home/ed/Downloads/netpy/")
sys.path.append("/home/ed/Downloads/netpy/debinterface/")
adapters = debinterface.interfaces()

I run this script within "/home/ed/Downloads/netpy/" that consists of "debinterface". I have to say that I tried that script without "sys.path.append" but nothing changed, even I changed the module name "debinterface" to "debeh" but again nothing changed too.

what is my problem?

Upvotes: 2

Views: 5584

Answers (2)

Pablo
Pablo

Reputation: 1319

Well, I got it working doing the following:

  1. Downloaded the zip from github;
  2. Extracted the zip and renamed it to debinterfaces;
  3. Created a python module in the same directory that debinterfaces folder is;
  4. Changed the import statement:

    from debinterface.interfaces import interfaces
    
  5. And finally, called interfaces:

    adapters = interfaces()
    

Upvotes: 0

xnx
xnx

Reputation: 25528

This looks like a bug in the documentation or the package code to me. You can use

from debinterface.interfaces import interfaces

and then refer to your the interface class with

adapters = interfaces()

or edit debinterface/__init__.py to do the import of interface module for you when you import the debinterface package. Add the line

from interfaces import interfaces

to the __init__.py file.

Upvotes: 2

Related Questions