How to use DNS resolver in Python 3?
Asked Answered
P

2

8

I want to check MX-Record from Python. So I installed the dnspython package, but when I try to import following library:

import dns.resolver

It shows the following error:

ModuleNotFoundError: No module named 'dns'.

I use PyCharm and Python 3.

Posture answered 2/1, 2018 at 5:30 Comment(6)
How did you install dns package? pip? If so please add pip list output as wellSpoofery
I install using pycharm.. ctrl+alt+S and click + sign there in python interpretor and search dnspython and install packagePosture
Can you try import resolver from dns and paste the error? Just to make sure the package is installed, look in the project interpreter and see that the package is listed.Spoofery
import resolver from dns gives SyntaxError: invalid syntax and from dns import resolver gives ModuleNotFoundError: No module named 'dns'Posture
In the project Interpreter can you see the package? Clearly it is installing somewhere outside your project scope. Mostly in a different virtual environment.Spoofery
Thank you for your help..I got my answer In python3 package is dnspython3 not dnspythonPosture
E
5

You should install https://github.com/rthalley/dnspython first

pip install dnspython

Elenoraelenore answered 29/8, 2018 at 14:4 Comment(0)
P
2

What solved it for me was to add dnspython into the requirements file.

So in the requirements.pinned.txt:

...
dnspython==2.0.0
...

And in the requirements.txt:

dnspython
...
Pyromania answered 2/3, 2023 at 14:18 Comment(0)

© 2022 - 2024 — McMap. All rights reserved.