ImportError: No module named dns.exception

TomSelleck picture TomSelleck · Sep 4, 2014 · Viewed 12.9k times · Source

I am trying to use the dnspython in my code but when it gets to the import statement, I get the following error:

>>> import DNS.resolver
Traceback (most recent call last):
  File "<stdin>", line 1, in <module>
  File "C:\python27\lib\site-packages\DNS\resolver.py", line 31, in <module>
    import dns.exception
ImportError: No module named dns.exception

I have tried installing with pip, easy_install and manually from the git repo but nothing seems to do the trick. Any ideas??

Code:

import DNS.resolver

if __name__ == "__main__":

    domain = 'hotmail.com'
    for x in dns.resolver.query(domain, 'MX'):
        print x.to_text()

Answer

Joanmacat picture Joanmacat · Sep 19, 2014

Another thing you can do to fix problems with this package is to install python-dnspython again using Synaptic. (Whether no having previous problems about duplicity)

Sometimes if you try to install this package using pip could appear some problems like that:

Command python setup.py egg_info failed with error code 1 in /tmp/pip_build_root/dnspython Storing debug log for failure in /root/.pip/pip.log

Using Synaptic cleans the old files and install the new ones, from that package. I know this issue is solved but I wanted to add more information about this :)