Unable to run impacket

Hey guys,

I’m trying to run the MS SQL client from Impacket but I’m getting the error:

Traceback (most recent call last):
File “mssqlclient.py”, line 24, in
from impacket.examples import logger
ImportError: No module named impacket.examples

Install impacket by cloning the git repository
I have python3 installed I hope you can help me.

@JorgeH said:

Hey guys,

I’m trying to run the MS SQL client from Impacket but I’m getting the error:

Traceback (most recent call last):
File “mssqlclient.py”, line 24, in
from impacket.examples import logger
ImportError: No module named impacket.examples

Install impacket by cloning the git repository
I have python3 installed I hope you can help me.

There are a lot of threads talking about impacket, assuming this is for Archtype.

There are a few things that could be causing the problem here.

That’s because the PATH, your user and root maybe not use the same python intepreter to run this program,

In some case, you can solve it by type python3 /path/to/mssqlclient.py rather than run it directly.

Traceback (most recent call last):
File “mssqlclient.py”, line 24, in
from impacket.examples import logger
ImportError: No module named impacket.examples

Install impacket by cloning the git repository
I have python3 installed I hope you can help me.

I had the same problem.

Run this command to verify your python version
python --version

Once you find that out lets get rid of the files that were made when you pip installed so that we can redo it.
For python 2.7: rm -rf /usr/local/lib/python2.7/dist-packages/impacket*
For python 3(replace x once you find the version): rm -rf /usr/local/lib/python3.x/dist-packages/impacket*

Great you’re all cleaned up. Now, get rid of your impacket directory
sudo rm -rf impacket

Now we reinstall impacket with git clone.
git clone GitHub - fortra/impacket: Impacket is a collection of Python classes for working with network protocols.

Go into your impacket directory: cd /pathto/impacket

NOW THIS IS VERY IMPORTANT:
For python3 type: sudo pip3 install .
DO NOT FORGET THE PERIOD AT THE END.
For python 2.xx type: sudo pip install .

Then you should be able to use the tool as implied with no problems. I hope this helps!

2 Likes

this ■■■■ module is killing me.

Hi there, i tried all of the above and still getting this:

Traceback (most recent call last):
  File "/usr/bin/impacket/examples/mssqlclient.py", line 169, in <module>
    ms_sql.connect()
  File "/usr/local/lib/python3.9/dist-packages/impacket/tds.py", line 531, in connect
    af, socktype, proto, canonname, sa = socket.getaddrinfo(self.server, self.port, 0, socket.SOCK_STREAM)[0]
  File "/usr/lib/python3.9/socket.py", line 953, in getaddrinfo
    for res in _socket.getaddrinfo(host, port, family, type, proto, flags):

I see you’re using Python 3.9 want to try my advice in the above thread but instead of python 3 use 3.9?

When I tried all the above, as previously commented, I am still getting the same message:
Traceback (most recent call last):
File “/usr/bin/impacket/examples/mssqlclient.py”, line 169, in
ms_sql.connect()
File “/usr/local/lib/python3.9/dist-packages/impacket/tds.py”, line 531, in connect
af, socktype, proto, canonname, sa = socket.getaddrinfo(self.server, self.port, 0, socket.SOCK_STREAM)[0]
File “/usr/lib/python3.9/socket.py”, line 953, in getaddrinfo
for res in _socket.getaddrinfo(host, port, family, type, proto, flags):