Question

I am having a problem with importing and using the dnspython or easyzone modules for Python in my Django project. I have also tried this script outside of DJango with the same issue so I am pretty sure the issue is unrelated to the framework.

I have a simple script that will open and parse zone file for the dns records inside. I have no issues importing the easyzone or dns modules, but when I try to access any of the methods inside I get this error:

Traceback (most recent call last):
    File "fabfile.py", line 6, in <module>
    z = easyzone.zone_from_file('example.com', '/var/namedb/example.com')
AttributeError: 'module' object has no attribute 'zone_from_file'

I have installed dnspython and easy install via easy_install with no issues. I can import the modules at the top of my script without error, it even shows me the path to the library in the IDE helper. But when trying to access any methods within easyzone or dns I get an error, also the code completion on the IDE will not list any methods either which leads me to believe it is a path issue or how I am importing them.

Here is my code where it fails:

import os
import csv
import easyzone
import dns

z = easyzone.zone_from_file('example.com', '/var/namedb/example.com')

Looking inside the module in the code I can clearly see these methods exist, what am I doing wrong to not be able to access them?

Was it helpful?

Solution

You need to correct the import; from the developer sourcecode hosting homepage:

from easyzone import easyzone
z = easyzone.zone_from_file('example.com', '/var/namedb/example.com')
Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top