Import error: no module named dns.query

I am trying to execute python code in windows ... the code contains the following lines:

from scapy import * import random import socket import dns.query 

but wen I compile it from the command line, it gives the following error:

 C:\Python25 > attack.py Traceback <most recent call last>: File "C:\Python25\attack.py", line 4 , in <module> import dns.query ImportError: No module named dns.query 

what could be the mistake ?? how can i solve this ?? is it because of the path or because the dns.query module does not compile

+4
source share
1 answer

This means that you do not have dnspython installed.

There are two ways to install dnspython:

1. A good way:

The easiest way to install any module is to install the installation tools. Installation tools are a bit like apt-get for ubuntu. where you say "easy_install" and he will get it and install it. To install setuptools, download the source from https://pypi.python.org/pypi/setuptools now exctract them. Inside the extracted directory will be the setup.py file. run Install python setup.py

This will install the installation tools on your system.

you can see the executable file c: \ python2x \ Scripts \ easy_install.exe (2x is the python version, for example 26, 27, etc.)

Now to install dnspython startup

c: \ python2x \ Scripts \ easy_install.exe dnspython

This should solve your problem, and now your script should work fine.

You can also put c: \ python2x \ Scripts on Windows PATH so that you don't have to put the whole path every time you want to install the module.

2.Bad way:

Although this method may not work if some dnspython-dependent modules are not available.

Download dnspython sources from http://www.dnspython.org/kits/1.10.0/ and extract it. now go to the extracted folder and run Install python setup.py

+9
source

All Articles