NetfilterQueue Import Error

Hi guys,

I am working through Zaid’s course (Learn Python & Ethical Hacking From Scratch) and am having some issues importing NetfilterQueue using PyCharm. I have installed the package using pip however when installing the package in PyCharm I keep getting an install error. Currently using pip version 19.3.1 and Python version 3.7.5.

Any help would be greatly appreciated!

Thanks :slight_smile:

What is the error?

I have kinda the same problem


The code look like this

Hope i can get some help with this :slight_smile:

I was able to duplicate the error. I did some research; seems to be a lot of trouble getting it to work with python3. I had problems with scapy with python3 also.

I can get it to work in python2. If you are okay with using python2, you might try what I did, switching to a python2 compiler. Steps I used:
Go to File menu -> Settings… -> select Project Interpreter under Project:[name of your project] -> you will see an icon to the right of the project interpreter drop-down box, it looks like a gear, select the icon -> select Add… -> select Existing Environment then [. . .] box to the far right of Interpreter: -> select usr then bin then python2.7 then OK.
After Python2.7 is showing as the project interpreter, choose the + icon next to the packages table to add a package -> type in NetfilterQueue and then select it, then select Install Package. Pycharm may do some processing for a few minutes.

I’m only a student, so I don’t know if I can help further. I’m still looking into how to get it working with python3. Hope this helps.

gdub - you are awsome :slight_smile:

1 Like

gdub - thanks, this also helped me get around the error as well, I’d like to still get it working in python3 though if possible, I also had some problems with scapy installing but managed to figure it out after installing a few dependencies… it seems to be what is missing for this netfilterqueue module as well…

note: I can get it to install using pip from a terminal after running:
apt-get install build-essential python-dev libnetfilter-queue-dev
then run:
pip install netfilterqueue

but it still will not allow me to install the module from within pycharm…

Hope someone can figure it out as I’d like to work with the module in python3 from within pycharm.
Thanks again.

EDIT: I managed to get it working for python 3.7 in pycharm, from what I can tell NetFilterQueue does not support python 3.8 yet and it will not let you import it… but to get it workng for python 3.7 I did the following…

from terminal I ran:
apt-get install libnetfilter-queue-dev

then I ran this to install netfilterqueue python 3 version:
pip3 install NFQP3

then I went into pycharm and changed my project interpreter to python3 by following the directions that gdub posted above except I selected python3 instead of python2.7.

Then I imported the module NFQP3 from within pycharm by clicking the + button and searching for NFQP3.

hope that helps.

1 Like

Nice job! Thanks for the update.

Im gettin through this course and lovin it but ran into another problem while trying to use netfilterqueue to set the payload of a packet…

packet.set_payload(str(scapy_packet))

returns an error…

Exception AttributeError: “‘netfilterqueue.Packet’ object has no attribute ‘set_payload’” in ‘netfilterqueue.global_callback’ ignored

Any ideas?

Have you tried installing a much earlier version of Python 3 in “venv” (virtual environment) and using that interpretor for that project? I would try Python 3.5 first.

Actually I figured it out, and for everyone whos had this problem with netfilterqueue, python seemed to come with version 0.6 of it installed which was out of date and then there was a split and 2 versions of netfilterqueue 0.8.1 were released, one of the versions set_payload was not implemented and missing, so I uninstalled netfilterqueue using:

pip remove NetfilterQueue

if you run that it downgrades you to 0.6 but wont remove it completely, then I went to

and used the method:

git clone git@github.com:kti/python-netfilterqueue.git
cd python-netfilterqueue
python setup.py install

to install the latest version of it and it fixed everything.
Hope that helps the rest of you out there having the same issue as well.

Thanks for the update!