Charalamm
Charalamm

Reputation: 1927

ModuleNotFoundError: No module named 'dnspython'

I am trying to import the module dnspython in a python 3.6 script using import dnspython.

pip3 freeze shows that the package is installed but I keep getting the error ModuleNotFoundError: No module named 'dnspython'

I have tried:

I am aware of this post for python 2.7 but none of the solutions worked.

Upvotes: 5

Views: 13550

Answers (2)

Victor Villacorta
Victor Villacorta

Reputation: 617

It worked for me (Python 3.8.5):

pip install dnspython3

code:

import dns
from dns import resolver 

result = resolver.resolve('google.com')
for ipval in result:
    print('IP', ipval.to_text())

Upvotes: 0

Charalamm
Charalamm

Reputation: 1927

The problem was import dnspython. Changing it into import dns worked fine.

Some test code:

import dns

result = dns.resolver.query('google.com', 'A')
for ipval in result:
    print('IP', ipval.to_text())

# Output: IP {your ip}

Upvotes: 12

Related Questions