简体   繁体   English

如何为 python3 安装 netfilterqueue?

[英]How do I install netfilterqueue for python3?

I am doing a project with python3.8 as my interpreter in pycharm.我在 pycharm 中使用 python3.8 作为我的解释器做一个项目。

How do I install netfilterqueue so that it works in python3?如何安装 netfilterqueue 以便它在 python3 中工作? I have tried to run the following command in my kali terminal but I get the following error:我尝试在我的 kali 终端中运行以下命令,但出现以下错误:

root@kali:~/PycharmProjects/dns_spoof# pip3 install netfilterqueue
Collecting netfilterqueue
  Cache entry deserialization failed, entry ignored
  Using cached https://files.pythonhosted.org/packages/39/c4/8f73f70442aa4094b3c37876c96cddad2c3e74c058f6cd9cb017d37ffac0/NetfilterQueue-0.8.1.tar.gz
Building wheels for collected packages: netfilterqueue
  Running setup.py bdist_wheel for netfilterqueue ... error
  Complete output from command /usr/bin/python3 -u -c "import setuptools, tokenize;__file__='/tmp/pip-install-evvln_9d/netfilterqueue/setup.py';f=getattr(tokenize, 'open', open)(__file__);code=f.read().replace('\r\n', '\n');f.close();exec(compile(code, __file__, 'exec'))" bdist_wheel -d /tmp/pip-wheel-z72tnt4e --python-tag cp37:
  running bdist_wheel
  running build
  running build_ext
  building 'netfilterqueue' extension
  creating build
  creating build/temp.linux-x86_64-3.7
  x86_64-linux-gnu-gcc -pthread -Wno-unused-result -Wsign-compare -DNDEBUG -g -fwrapv -O2 -Wall -g -fstack-protector-strong -Wformat -Werror=format-security -g -fwrapv -O2 -g -fstack-protector-strong -Wformat -Werror=format-security -Wdate-time -D_FORTIFY_SOURCE=2 -fPIC -I/usr/include/python3.7m -c netfilterqueue.c -o build/temp.linux-x86_64-3.7/netfilterqueue.o
  netfilterqueue.c: In function ‘__pyx_f_14netfilterqueue_6Packet_set_nfq_data’:
  netfilterqueue.c:2150:68: warning: passing argument 2 of ‘nfq_get_payload’ from incompatible pointer type [-Wincompatible-pointer-types]
   2150 |   __pyx_v_self->payload_len = nfq_get_payload(__pyx_v_self->_nfa, (&__pyx_v_self->payload));
        |                                                                   ~^~~~~~~~~~~~~~~~~~~~~~~
        |                                                                    |
        |                                                                    char **
  In file included from netfilterqueue.c:440:
  /usr/include/libnetfilter_queue/libnetfilter_queue.h:122:67: note: expected ‘unsigned char **’ but argument is of type ‘char **’
    122 | extern int nfq_get_payload(struct nfq_data *nfad, unsigned char **data);
        |                                                   ~~~~~~~~~~~~~~~~^~~~
  netfilterqueue.c: In function ‘__pyx_pf_14netfilterqueue_6Packet_4get_hw’:
  netfilterqueue.c:2533:17: warning: implicit declaration of function ‘PyString_FromStringAndSize’; did you mean ‘PyBytes_FromStringAndSize’? [-Wimplicit-function-declaration]
   2533 |     __pyx_t_3 = PyString_FromStringAndSize(((char *)__pyx_v_self->hw_addr), 8); if (unlikely(!__pyx_t_3)) __PYX_ERR(0, 111, __pyx_L1_error)
        |                 ^~~~~~~~~~~~~~~~~~~~~~~~~~
        |                 PyBytes_FromStringAndSize
  netfilterqueue.c:2533:15: warning: assignment to ‘PyObject *’ {aka ‘struct _object *’} from ‘int’ makes pointer from integer without a cast [-Wint-conversion]
   2533 |     __pyx_t_3 = PyString_FromStringAndSize(((char *)__pyx_v_self->hw_addr), 8); if (unlikely(!__pyx_t_3)) __PYX_ERR(0, 111, __pyx_L1_error)
        |               ^
  netfilterqueue.c: In function ‘__Pyx_PyCFunction_FastCall’:
  netfilterqueue.c:6436:13: error: too many arguments to function ‘(PyObject * (*)(PyObject *, PyObject * const*, Py_ssize_t))meth’
   6436 |     return (*((__Pyx_PyCFunctionFast)meth)) (self, args, nargs, NULL);
        |            ~^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
  netfilterqueue.c: In function ‘__Pyx__ExceptionSave’:
  netfilterqueue.c:7132:21: error: ‘PyThreadState’ {aka ‘struct _ts’} has no member named ‘exc_type’; did you mean ‘curexc_type’?
   7132 |     *type = tstate->exc_type;
        |                     ^~~~~~~~
        |                     curexc_type
  netfilterqueue.c:7133:22: error: ‘PyThreadState’ {aka ‘struct _ts’} has no member named ‘exc_value’; did you mean ‘curexc_value’?
   7133 |     *value = tstate->exc_value;
        |                      ^~~~~~~~~
        |                      curexc_value
  netfilterqueue.c:7134:19: error: ‘PyThreadState’ {aka ‘struct _ts’} has no member named ‘exc_traceback’; did you mean ‘curexc_traceback’?
   7134 |     *tb = tstate->exc_traceback;
        |                   ^~~~~~~~~~~~~
        |                   curexc_traceback
  netfilterqueue.c: In function ‘__Pyx__ExceptionReset’:
  netfilterqueue.c:7141:24: error: ‘PyThreadState’ {aka ‘struct _ts’} has no member named ‘exc_type’; did you mean ‘curexc_type’?
   7141 |     tmp_type = tstate->exc_type;
        |                        ^~~~~~~~
        |                        curexc_type
  netfilterqueue.c:7142:25: error: ‘PyThreadState’ {aka ‘struct _ts’} has no member named ‘exc_value’; did you mean ‘curexc_value’?
   7142 |     tmp_value = tstate->exc_value;
        |                         ^~~~~~~~~
        |                         curexc_value
  netfilterqueue.c:7143:22: error: ‘PyThreadState’ {aka ‘struct _ts’} has no member named ‘exc_traceback’; did you mean ‘curexc_traceback’?
   7143 |     tmp_tb = tstate->exc_traceback;
        |                      ^~~~~~~~~~~~~
        |                      curexc_traceback
  netfilterqueue.c:7144:13: error: ‘PyThreadState’ {aka ‘struct _ts’} has no member named ‘exc_type’; did you mean ‘curexc_type’?
   7144 |     tstate->exc_type = type;
        |             ^~~~~~~~
        |             curexc_type
  netfilterqueue.c:7145:13: error: ‘PyThreadState’ {aka ‘struct _ts’} has no member named ‘exc_value’; did you mean ‘curexc_value’?
   7145 |     tstate->exc_value = value;
        |             ^~~~~~~~~
        |             curexc_value
  netfilterqueue.c:7146:13: error: ‘PyThreadState’ {aka ‘struct _ts’} has no member named ‘exc_traceback’; did you mean ‘curexc_traceback’?
   7146 |     tstate->exc_traceback = tb;
        |             ^~~~~~~~~~~~~
        |             curexc_traceback
  netfilterqueue.c: In function ‘__Pyx__GetException’:
  netfilterqueue.c:7201:24: error: ‘PyThreadState’ {aka ‘struct _ts’} has no member named ‘exc_type’; did you mean ‘curexc_type’?
   7201 |     tmp_type = tstate->exc_type;
        |                        ^~~~~~~~
        |                        curexc_type
  netfilterqueue.c:7202:25: error: ‘PyThreadState’ {aka ‘struct _ts’} has no member named ‘exc_value’; did you mean ‘curexc_value’?
   7202 |     tmp_value = tstate->exc_value;
        |                         ^~~~~~~~~
        |                         curexc_value
  netfilterqueue.c:7203:22: error: ‘PyThreadState’ {aka ‘struct _ts’} has no member named ‘exc_traceback’; did you mean ‘curexc_traceback’?
   7203 |     tmp_tb = tstate->exc_traceback;
        |                      ^~~~~~~~~~~~~
        |                      curexc_traceback
  netfilterqueue.c:7204:13: error: ‘PyThreadState’ {aka ‘struct _ts’} has no member named ‘exc_type’; did you mean ‘curexc_type’?
   7204 |     tstate->exc_type = local_type;
        |             ^~~~~~~~
        |             curexc_type
  netfilterqueue.c:7205:13: error: ‘PyThreadState’ {aka ‘struct _ts’} has no member named ‘exc_value’; did you mean ‘curexc_value’?
   7205 |     tstate->exc_value = local_value;
        |             ^~~~~~~~~
        |             curexc_value
  netfilterqueue.c:7206:13: error: ‘PyThreadState’ {aka ‘struct _ts’} has no member named ‘exc_traceback’; did you mean ‘curexc_traceback’?
   7206 |     tstate->exc_traceback = local_tb;
        |             ^~~~~~~~~~~~~
        |             curexc_traceback
  error: command 'x86_64-linux-gnu-gcc' failed with exit status 1

  ----------------------------------------
  Failed building wheel for netfilterqueue
  Running setup.py clean for netfilterqueue
Failed to build netfilterqueue
Installing collected packages: netfilterqueue
  Running setup.py install for netfilterqueue ... error
    Complete output from command /usr/bin/python3 -u -c "import setuptools, tokenize;__file__='/tmp/pip-install-evvln_9d/netfilterqueue/setup.py';f=getattr(tokenize, 'open', open)(__file__);code=f.read().replace('\r\n', '\n');f.close();exec(compile(code, __file__, 'exec'))" install --record /tmp/pip-record-7hb6tfdl/install-record.txt --single-version-externally-managed --compile:
    running install
    running build
    running build_ext
    building 'netfilterqueue' extension
    creating build
    creating build/temp.linux-x86_64-3.7
    x86_64-linux-gnu-gcc -pthread -Wno-unused-result -Wsign-compare -DNDEBUG -g -fwrapv -O2 -Wall -g -fstack-protector-strong -Wformat -Werror=format-security -g -fwrapv -O2 -g -fstack-protector-strong -Wformat -Werror=format-security -Wdate-time -D_FORTIFY_SOURCE=2 -fPIC -I/usr/include/python3.7m -c netfilterqueue.c -o build/temp.linux-x86_64-3.7/netfilterqueue.o
    netfilterqueue.c: In function ‘__pyx_f_14netfilterqueue_6Packet_set_nfq_data’:
    netfilterqueue.c:2150:68: warning: passing argument 2 of ‘nfq_get_payload’ from incompatible pointer type [-Wincompatible-pointer-types]
     2150 |   __pyx_v_self->payload_len = nfq_get_payload(__pyx_v_self->_nfa, (&__pyx_v_self->payload));
          |                                                                   ~^~~~~~~~~~~~~~~~~~~~~~~
          |                                                                    |
          |                                                                    char **
    In file included from netfilterqueue.c:440:
    /usr/include/libnetfilter_queue/libnetfilter_queue.h:122:67: note: expected ‘unsigned char **’ but argument is of type ‘char **’
      122 | extern int nfq_get_payload(struct nfq_data *nfad, unsigned char **data);
          |                                                   ~~~~~~~~~~~~~~~~^~~~
    netfilterqueue.c: In function ‘__pyx_pf_14netfilterqueue_6Packet_4get_hw’:
    netfilterqueue.c:2533:17: warning: implicit declaration of function ‘PyString_FromStringAndSize’; did you mean ‘PyBytes_FromStringAndSize’? [-Wimplicit-function-declaration]
     2533 |     __pyx_t_3 = PyString_FromStringAndSize(((char *)__pyx_v_self->hw_addr), 8); if (unlikely(!__pyx_t_3)) __PYX_ERR(0, 111, __pyx_L1_error)
          |                 ^~~~~~~~~~~~~~~~~~~~~~~~~~
          |                 PyBytes_FromStringAndSize
    netfilterqueue.c:2533:15: warning: assignment to ‘PyObject *’ {aka ‘struct _object *’} from ‘int’ makes pointer from integer without a cast [-Wint-conversion]
     2533 |     __pyx_t_3 = PyString_FromStringAndSize(((char *)__pyx_v_self->hw_addr), 8); if (unlikely(!__pyx_t_3)) __PYX_ERR(0, 111, __pyx_L1_error)
          |               ^
    netfilterqueue.c: In function ‘__Pyx_PyCFunction_FastCall’:
    netfilterqueue.c:6436:13: error: too many arguments to function ‘(PyObject * (*)(PyObject *, PyObject * const*, Py_ssize_t))meth’
     6436 |     return (*((__Pyx_PyCFunctionFast)meth)) (self, args, nargs, NULL);
          |            ~^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
    netfilterqueue.c: In function ‘__Pyx__ExceptionSave’:
    netfilterqueue.c:7132:21: error: ‘PyThreadState’ {aka ‘struct _ts’} has no member named ‘exc_type’; did you mean ‘curexc_type’?
     7132 |     *type = tstate->exc_type;
          |                     ^~~~~~~~
          |                     curexc_type
    netfilterqueue.c:7133:22: error: ‘PyThreadState’ {aka ‘struct _ts’} has no member named ‘exc_value’; did you mean ‘curexc_value’?
     7133 |     *value = tstate->exc_value;
          |                      ^~~~~~~~~
          |                      curexc_value
    netfilterqueue.c:7134:19: error: ‘PyThreadState’ {aka ‘struct _ts’} has no member named ‘exc_traceback’; did you mean ‘curexc_traceback’?
     7134 |     *tb = tstate->exc_traceback;
          |                   ^~~~~~~~~~~~~
          |                   curexc_traceback
    netfilterqueue.c: In function ‘__Pyx__ExceptionReset’:
    netfilterqueue.c:7141:24: error: ‘PyThreadState’ {aka ‘struct _ts’} has no member named ‘exc_type’; did you mean ‘curexc_type’?
     7141 |     tmp_type = tstate->exc_type;
          |                        ^~~~~~~~
          |                        curexc_type
    netfilterqueue.c:7142:25: error: ‘PyThreadState’ {aka ‘struct _ts’} has no member named ‘exc_value’; did you mean ‘curexc_value’?
     7142 |     tmp_value = tstate->exc_value;
          |                         ^~~~~~~~~
          |                         curexc_value
    netfilterqueue.c:7143:22: error: ‘PyThreadState’ {aka ‘struct _ts’} has no member named ‘exc_traceback’; did you mean ‘curexc_traceback’?
     7143 |     tmp_tb = tstate->exc_traceback;
          |                      ^~~~~~~~~~~~~
          |                      curexc_traceback
    netfilterqueue.c:7144:13: error: ‘PyThreadState’ {aka ‘struct _ts’} has no member named ‘exc_type’; did you mean ‘curexc_type’?
     7144 |     tstate->exc_type = type;
          |             ^~~~~~~~
          |             curexc_type
    netfilterqueue.c:7145:13: error: ‘PyThreadState’ {aka ‘struct _ts’} has no member named ‘exc_value’; did you mean ‘curexc_value’?
     7145 |     tstate->exc_value = value;
          |             ^~~~~~~~~
          |             curexc_value
    netfilterqueue.c:7146:13: error: ‘PyThreadState’ {aka ‘struct _ts’} has no member named ‘exc_traceback’; did you mean ‘curexc_traceback’?
     7146 |     tstate->exc_traceback = tb;
          |             ^~~~~~~~~~~~~
          |             curexc_traceback
    netfilterqueue.c: In function ‘__Pyx__GetException’:
    netfilterqueue.c:7201:24: error: ‘PyThreadState’ {aka ‘struct _ts’} has no member named ‘exc_type’; did you mean ‘curexc_type’?
     7201 |     tmp_type = tstate->exc_type;
          |                        ^~~~~~~~
          |                        curexc_type
    netfilterqueue.c:7202:25: error: ‘PyThreadState’ {aka ‘struct _ts’} has no member named ‘exc_value’; did you mean ‘curexc_value’?
     7202 |     tmp_value = tstate->exc_value;
          |                         ^~~~~~~~~
          |                         curexc_value
    netfilterqueue.c:7203:22: error: ‘PyThreadState’ {aka ‘struct _ts’} has no member named ‘exc_traceback’; did you mean ‘curexc_traceback’?
     7203 |     tmp_tb = tstate->exc_traceback;
          |                      ^~~~~~~~~~~~~
          |                      curexc_traceback
    netfilterqueue.c:7204:13: error: ‘PyThreadState’ {aka ‘struct _ts’} has no member named ‘exc_type’; did you mean ‘curexc_type’?
     7204 |     tstate->exc_type = local_type;
          |             ^~~~~~~~
          |             curexc_type
    netfilterqueue.c:7205:13: error: ‘PyThreadState’ {aka ‘struct _ts’} has no member named ‘exc_value’; did you mean ‘curexc_value’?
     7205 |     tstate->exc_value = local_value;
          |             ^~~~~~~~~
          |             curexc_value
    netfilterqueue.c:7206:13: error: ‘PyThreadState’ {aka ‘struct _ts’} has no member named ‘exc_traceback’; did you mean ‘curexc_traceback’?
     7206 |     tstate->exc_traceback = local_tb;
          |             ^~~~~~~~~~~~~
          |             curexc_traceback
    error: command 'x86_64-linux-gnu-gcc' failed with exit status 1

    ----------------------------------------
Command "/usr/bin/python3 -u -c "import setuptools, tokenize;__file__='/tmp/pip-install-evvln_9d/netfilterqueue/setup.py';f=getattr(tokenize, 'open', open)(__file__);code=f.read().replace('\r\n', '\n');f.close();exec(compile(code, __file__, 'exec'))" install --record /tmp/pip-record-7hb6tfdl/install-record.txt --single-version-externally-managed --compile" failed with error code 1 in /tmp/pip-install-evvln_9d/netfilterqueue/

After the error I have tried to run "pip uninstall netfilterqueue" and "pip3 uninstall netfilterqueue" and then "pip3 install netfilterqueue" again but I still get the same error.出现错误后,我尝试运行“pip uninstall netfilterqueue”和“pip3 uninstall netfilterqueue”,然后再次运行“pip3 install netfilterqueue”,但我仍然遇到同样的错误。

How do I solve this?我该如何解决这个问题?

It looks like NetfilterQueue package doesn't support python 3.7+.看起来 NetfilterQueue package 不支持 python 3.7+。 They don't provide such information on the site, but I tried building it and I got the same errors on 3.7, when it compiles fine for 3.6.他们没有在网站上提供此类信息,但我尝试构建它,但我在 3.7 上遇到了同样的错误,当它为 3.6 编译正常时。

That would make sense because the pip package was released: Jan 31, 2017 and python3.7 on 2018.这是有道理的,因为 pip package 于 2017 年 1 月 31 日发布,python3.7 于 2018 年发布。

hello first install netfilterqueue on your linux machine您好,首先在您的 linux 机器上安装 netfilterqueue

sudo apt install libnfnetlink-dev libnetfilter-queue-dev

then you should know netfilterqueue for python3+ is named nfqp3 so install it with那么你应该知道 python3+ 的 netfilterqueue 被命名为 nfqp3 所以安装它

pip3 install nfqp3

it is worth mentioning that when importing it in a python script you should import it as netfilterqueue not nfqp3值得一提的是,在 python 脚本中导入它时,您应该将其导入为 netfilterqueue 而不是 nfqp3

It worked after I installed this:我安装后它起作用了:

  1. sudo apt-get install build-essential python-dev libnetfilter-queue-dev
  2. pip install NetfilterQueue or pip3 install NetfilterQueue pip install NetfilterQueuepip3 install NetfilterQueue

My python3 version is 3.6.9我的python3版本是3.6.9

The project is abandoned but there are forks that fix this issue.该项目已被放弃,但有一些分支可以解决此问题。 https://github.com/kti/python-netfilterqueue/pull/60 especially upgrades netfilterqueue to build on modern Cython, allowing it to support Python > 3.6. https://github.com/kti/python-netfilterqueue/pull/60特别升级了 netfilterqueue 以建立在现代 Cython 上,使其支持 Python > 3.6。 You can try using that branch您可以尝试使用该分支

pip install https://github.com/johnteslade/python-netfilterqueue/archive/refs/heads/update-cython-code.zip

you will find the solution here:你会在这里找到解决方案:

https://github.com/kti/python-netfilterqueue/issues/53 https://github.com/kti/python-netfilterqueue/issues/53

Specially this answer:特别是这个答案:

pip3 install -U git+https://github.com/kti/python-netfilterqueue

Collecting git+https://github.com/kti/python-netfilterqueue
  Cloning https://github.com/kti/python-netfilterqueue to /tmp/pip-req-build-ltdpna35
  Running command git clone -q https://github.com/kti/python-netfilterqueue /tmp/pip-req-build-ltdpna35
Building wheels for collected packages: NetfilterQueue
  Building wheel for NetfilterQueue (setup.py) ... error
  ERROR: Command errored out with exit status 1:
   command: /usr/bin/python3 -u -c 'import sys, setuptools, tokenize; sys.argv[0] = '"'"'/tmp/pip-req-build-ltdpna35/setup.py'"'"'; __file__='"'"'/tmp/pip-req-build-ltdpna35/setup.py'"'"';f=getattr(tokenize, '"'"'open'"'"', open)(__file__);code=f.read().replace('"'"'\r\n'"'"', '"'"'\n'"'"');f.close();exec(compile(code, __file__, '"'"'exec'"'"'))' bdist_wheel -d /tmp/pip-wheel-jnalmd3v
       cwd: /tmp/pip-req-build-ltdpna35/
  Complete output (143 lines):
  running bdist_wheel
  running build
  running build_ext
  skipping 'netfilterqueue.c' Cython extension (up-to-date)
  building 'netfilterqueue' extension
  creating build
  creating build/temp.linux-x86_64-3.9
  x86_64-linux-gnu-gcc -pthread -Wno-unused-result -Wsign-compare -DNDEBUG -g -fwrapv -O2 -Wall -g -fstack-protector-strong -Wformat -Werror=format-security -g -fwrapv -O2 -g -fstack-protector-strong -Wformat -Werror=format-security -Wdate-time -D_FORTIFY_SOURCE=2 -fPIC -I/usr/include/python3.9 -c netfilterqueue.c -o build/temp.linux-x86_64-3.9/netfilterqueue.o
  netfilterqueue.c: In function ‘__pyx_f_14netfilterqueue_6Packet_set_nfq_data’:
  netfilterqueue.c:2150:68: warning: passing argument 2 of ‘nfq_get_payload’ from incompatible pointer type [-Wincompatible-pointer-types]
   2150 |   __pyx_v_self->payload_len = nfq_get_payload(__pyx_v_self->_nfa, (&__pyx_v_self->payload));
        |                                                                   ~^~~~~~~~~~~~~~~~~~~~~~~
        |                                                                    |
        |                                                                    char **
  In file included from netfilterqueue.c:440:
  /usr/include/libnetfilter_queue/libnetfilter_queue.h:123:67: note: expected ‘unsigned char **’ but argument is of type ‘char **’
    123 | extern int nfq_get_payload(struct nfq_data *nfad, unsigned char **data);
        |                                                   ~~~~~~~~~~~~~~~~^~~~
  netfilterqueue.c: In function ‘__pyx_pf_14netfilterqueue_6Packet_4get_hw’:
  netfilterqueue.c:2533:17: warning: implicit declaration of function ‘PyString_FromStringAndSize’; did you mean ‘PyBytes_FromStringAndSize’? [-Wimplicit-function-declaration]
   2533 |     __pyx_t_3 = PyString_FromStringAndSize(((char *)__pyx_v_self->hw_addr), 8); if (unlikely(!__pyx_t_3)) __PYX_ERR(0, 111, __pyx_L1_error)
        |                 ^~~~~~~~~~~~~~~~~~~~~~~~~~
        |                 PyBytes_FromStringAndSize
  netfilterqueue.c:2533:15: warning: assignment to ‘PyObject *’ {aka ‘struct _object *’} from ‘int’ makes pointer from integer without a cast [-Wint-conversion]
   2533 |     __pyx_t_3 = PyString_FromStringAndSize(((char *)__pyx_v_self->hw_addr), 8); if (unlikely(!__pyx_t_3)) __PYX_ERR(0, 111, __pyx_L1_error)
        |               ^
  netfilterqueue.c: In function ‘PyInit_netfilterqueue’:
  netfilterqueue.c:6111:37: error: ‘PyTypeObject’ {aka ‘struct _typeobject’} has no member named ‘tp_print’
   6111 |   __pyx_type_14netfilterqueue_Packet.tp_print = 0;
        |                                     ^
  netfilterqueue.c:6116:45: error: ‘PyTypeObject’ {aka ‘struct _typeobject’} has no member named ‘tp_print’
   6116 |   __pyx_type_14netfilterqueue_NetfilterQueue.tp_print = 0;
        |                                             ^
  netfilterqueue.c: In function ‘__Pyx_ParseOptionalKeywords’:
  netfilterqueue.c:7076:21: warning: ‘_PyUnicode_get_wstr_length’ is deprecated [-Wdeprecated-declarations]
   7076 |                     (PyUnicode_GET_SIZE(**name) != PyUnicode_GET_SIZE(key)) ? 1 :
        |                     ^
  In file included from /usr/include/python3.9/unicodeobject.h:1026,
                   from /usr/include/python3.9/Python.h:93,
                   from netfilterqueue.c:4:
  /usr/include/python3.9/cpython/unicodeobject.h:446:26: note: declared here
    446 | static inline Py_ssize_t _PyUnicode_get_wstr_length(PyObject *op) {
        |                          ^~~~~~~~~~~~~~~~~~~~~~~~~~
  netfilterqueue.c:7076:21: warning: ‘PyUnicode_AsUnicode’ is deprecated [-Wdeprecated-declarations]
   7076 |                     (PyUnicode_GET_SIZE(**name) != PyUnicode_GET_SIZE(key)) ? 1 :
        |                     ^
  In file included from /usr/include/python3.9/unicodeobject.h:1026,
                   from /usr/include/python3.9/Python.h:93,
                   from netfilterqueue.c:4:
  /usr/include/python3.9/cpython/unicodeobject.h:580:45: note: declared here
    580 | Py_DEPRECATED(3.3) PyAPI_FUNC(Py_UNICODE *) PyUnicode_AsUnicode(
        |                                             ^~~~~~~~~~~~~~~~~~~
  netfilterqueue.c:7076:21: warning: ‘_PyUnicode_get_wstr_length’ is deprecated [-Wdeprecated-declarations]
   7076 |                     (PyUnicode_GET_SIZE(**name) != PyUnicode_GET_SIZE(key)) ? 1 :
        |                     ^
  In file included from /usr/include/python3.9/unicodeobject.h:1026,
                   from /usr/include/python3.9/Python.h:93,
                   from netfilterqueue.c:4:
  /usr/include/python3.9/cpython/unicodeobject.h:446:26: note: declared here
    446 | static inline Py_ssize_t _PyUnicode_get_wstr_length(PyObject *op) {
        |                          ^~~~~~~~~~~~~~~~~~~~~~~~~~
  netfilterqueue.c:7076:21: warning: ‘_PyUnicode_get_wstr_length’ is deprecated [-Wdeprecated-declarations]
   7076 |                     (PyUnicode_GET_SIZE(**name) != PyUnicode_GET_SIZE(key)) ? 1 :
        |                     ^
  In file included from /usr/include/python3.9/unicodeobject.h:1026,
                   from /usr/include/python3.9/Python.h:93,
                   from netfilterqueue.c:4:
  /usr/include/python3.9/cpython/unicodeobject.h:446:26: note: declared here
    446 | static inline Py_ssize_t _PyUnicode_get_wstr_length(PyObject *op) {
        |                          ^~~~~~~~~~~~~~~~~~~~~~~~~~
  netfilterqueue.c:7076:21: warning: ‘PyUnicode_AsUnicode’ is deprecated [-Wdeprecated-declarations]
   7076 |                     (PyUnicode_GET_SIZE(**name) != PyUnicode_GET_SIZE(key)) ? 1 :
        |                     ^
  In file included from /usr/include/python3.9/unicodeobject.h:1026,
                   from /usr/include/python3.9/Python.h:93,
                   from netfilterqueue.c:4:
  /usr/include/python3.9/cpython/unicodeobject.h:580:45: note: declared here
    580 | Py_DEPRECATED(3.3) PyAPI_FUNC(Py_UNICODE *) PyUnicode_AsUnicode(
        |                                             ^~~~~~~~~~~~~~~~~~~
  netfilterqueue.c:7076:21: warning: ‘_PyUnicode_get_wstr_length’ is deprecated [-Wdeprecated-declarations]
   7076 |                     (PyUnicode_GET_SIZE(**name) != PyUnicode_GET_SIZE(key)) ? 1 :
        |                     ^
  In file included from /usr/include/python3.9/unicodeobject.h:1026,
                   from /usr/include/python3.9/Python.h:93,
                   from netfilterqueue.c:4:
  /usr/include/python3.9/cpython/unicodeobject.h:446:26: note: declared here
    446 | static inline Py_ssize_t _PyUnicode_get_wstr_length(PyObject *op) {
        |                          ^~~~~~~~~~~~~~~~~~~~~~~~~~
  netfilterqueue.c:7092:25: warning: ‘_PyUnicode_get_wstr_length’ is deprecated [-Wdeprecated-declarations]
   7092 |                         (PyUnicode_GET_SIZE(**argname) != PyUnicode_GET_SIZE(key)) ? 1 :
        |                         ^
  In file included from /usr/include/python3.9/unicodeobject.h:1026,
                   from /usr/include/python3.9/Python.h:93,
                   from netfilterqueue.c:4:
  /usr/include/python3.9/cpython/unicodeobject.h:446:26: note: declared here
    446 | static inline Py_ssize_t _PyUnicode_get_wstr_length(PyObject *op) {
        |                          ^~~~~~~~~~~~~~~~~~~~~~~~~~
  netfilterqueue.c:7092:25: warning: ‘PyUnicode_AsUnicode’ is deprecated [-Wdeprecated-declarations]
   7092 |                         (PyUnicode_GET_SIZE(**argname) != PyUnicode_GET_SIZE(key)) ? 1 :
        |                         ^
  In file included from /usr/include/python3.9/unicodeobject.h:1026,
                   from /usr/include/python3.9/Python.h:93,
                   from netfilterqueue.c:4:
  /usr/include/python3.9/cpython/unicodeobject.h:580:45: note: declared here
    580 | Py_DEPRECATED(3.3) PyAPI_FUNC(Py_UNICODE *) PyUnicode_AsUnicode(
        |                                             ^~~~~~~~~~~~~~~~~~~
  netfilterqueue.c:7092:25: warning: ‘_PyUnicode_get_wstr_length’ is deprecated [-Wdeprecated-declarations]
   7092 |                         (PyUnicode_GET_SIZE(**argname) != PyUnicode_GET_SIZE(key)) ? 1 :
        |                         ^
  In file included from /usr/include/python3.9/unicodeobject.h:1026,
                   from /usr/include/python3.9/Python.h:93,
                   from netfilterqueue.c:4:
  /usr/include/python3.9/cpython/unicodeobject.h:446:26: note: declared here
    446 | static inline Py_ssize_t _PyUnicode_get_wstr_length(PyObject *op) {
        |                          ^~~~~~~~~~~~~~~~~~~~~~~~~~
  netfilterqueue.c:7092:25: warning: ‘_PyUnicode_get_wstr_length’ is deprecated [-Wdeprecated-declarations]
   7092 |                         (PyUnicode_GET_SIZE(**argname) != PyUnicode_GET_SIZE(key)) ? 1 :
        |                         ^
  In file included from /usr/include/python3.9/unicodeobject.h:1026,
                   from /usr/include/python3.9/Python.h:93,
                   from netfilterqueue.c:4:
  /usr/include/python3.9/cpython/unicodeobject.h:446:26: note: declared here
    446 | static inline Py_ssize_t _PyUnicode_get_wstr_length(PyObject *op) {
        |                          ^~~~~~~~~~~~~~~~~~~~~~~~~~
  netfilterqueue.c:7092:25: warning: ‘PyUnicode_AsUnicode’ is deprecated [-Wdeprecated-declarations]
   7092 |                         (PyUnicode_GET_SIZE(**argname) != PyUnicode_GET_SIZE(key)) ? 1 :
        |                         ^
  In file included from /usr/include/python3.9/unicodeobject.h:1026,
                   from /usr/include/python3.9/Python.h:93,
                   from netfilterqueue.c:4:
  /usr/include/python3.9/cpython/unicodeobject.h:580:45: note: declared here
    580 | Py_DEPRECATED(3.3) PyAPI_FUNC(Py_UNICODE *) PyUnicode_AsUnicode(
        |                                             ^~~~~~~~~~~~~~~~~~~
  netfilterqueue.c:7092:25: warning: ‘_PyUnicode_get_wstr_length’ is deprecated [-Wdeprecated-declarations]
   7092 |                         (PyUnicode_GET_SIZE(**argname) != PyUnicode_GET_SIZE(key)) ? 1 :
        |                         ^
  In file included from /usr/include/python3.9/unicodeobject.h:1026,
                   from /usr/include/python3.9/Python.h:93,
                   from netfilterqueue.c:4:
  /usr/include/python3.9/cpython/unicodeobject.h:446:26: note: declared here
    446 | static inline Py_ssize_t _PyUnicode_get_wstr_length(PyObject *op) {
        |                          ^~~~~~~~~~~~~~~~~~~~~~~~~~
  error: command '/usr/bin/x86_64-linux-gnu-gcc' failed with exit code 1
  ----------------------------------------
  ERROR: Failed building wheel for NetfilterQueue
  Running setup.py clean for NetfilterQueue
Failed to build NetfilterQueue
Installing collected packages: NetfilterQueue
    Running setup.py install for NetfilterQueue ... error
    ERROR: Command errored out with exit status 1:
     command: /usr/bin/python3 -u -c 'import sys, setuptools, tokenize; sys.argv[0] = '"'"'/tmp/pip-req-build-ltdpna35/setup.py'"'"'; __file__='"'"'/tmp/pip-req-build-ltdpna35/setup.py'"'"';f=getattr(tokenize, '"'"'open'"'"', open)(__file__);code=f.read().replace('"'"'\r\n'"'"', '"'"'\n'"'"');f.close();exec(compile(code, __file__, '"'"'exec'"'"'))' install --record /tmp/pip-record-vncvx8bc/install-record.txt --single-version-externally-managed --compile --install-headers /usr/local/include/python3.9/NetfilterQueue
         cwd: /tmp/pip-req-build-ltdpna35/
    Complete output (143 lines):
    running install
    running build
    running build_ext
    skipping 'netfilterqueue.c' Cython extension (up-to-date)
    building 'netfilterqueue' extension
    creating build
    creating build/temp.linux-x86_64-3.9
    x86_64-linux-gnu-gcc -pthread -Wno-unused-result -Wsign-compare -DNDEBUG -g -fwrapv -O2 -Wall -g -fstack-protector-strong -Wformat -Werror=format-security -g -fwrapv -O2 -g -fstack-protector-strong -Wformat -Werror=format-security -Wdate-time -D_FORTIFY_SOURCE=2 -fPIC -I/usr/include/python3.9 -c netfilterqueue.c -o build/temp.linux-x86_64-3.9/netfilterqueue.o
    netfilterqueue.c: In function ‘__pyx_f_14netfilterqueue_6Packet_set_nfq_data’:
    netfilterqueue.c:2150:68: warning: passing argument 2 of ‘nfq_get_payload’ from incompatible pointer type [-Wincompatible-pointer-types]
     2150 |   __pyx_v_self->payload_len = nfq_get_payload(__pyx_v_self->_nfa, (&__pyx_v_self->payload));
          |                                                                   ~^~~~~~~~~~~~~~~~~~~~~~~
          |                                                                    |
          |                                                                    char **
    In file included from netfilterqueue.c:440:
    /usr/include/libnetfilter_queue/libnetfilter_queue.h:123:67: note: expected ‘unsigned char **’ but argument is of type ‘char **’
      123 | extern int nfq_get_payload(struct nfq_data *nfad, unsigned char **data);
          |                                                   ~~~~~~~~~~~~~~~~^~~~
    netfilterqueue.c: In function ‘__pyx_pf_14netfilterqueue_6Packet_4get_hw’:
    netfilterqueue.c:2533:17: warning: implicit declaration of function ‘PyString_FromStringAndSize’; did you mean ‘PyBytes_FromStringAndSize’? [-Wimplicit-function-declaration]
     2533 |     __pyx_t_3 = PyString_FromStringAndSize(((char *)__pyx_v_self->hw_addr), 8); if (unlikely(!__pyx_t_3)) __PYX_ERR(0, 111, __pyx_L1_error)
          |                 ^~~~~~~~~~~~~~~~~~~~~~~~~~
          |                 PyBytes_FromStringAndSize
    netfilterqueue.c:2533:15: warning: assignment to ‘PyObject *’ {aka ‘struct _object *’} from ‘int’ makes pointer from integer without a cast [-Wint-conversion]
     2533 |     __pyx_t_3 = PyString_FromStringAndSize(((char *)__pyx_v_self->hw_addr), 8); if (unlikely(!__pyx_t_3)) __PYX_ERR(0, 111, __pyx_L1_error)
          |               ^
    netfilterqueue.c: In function ‘PyInit_netfilterqueue’:
    netfilterqueue.c:6111:37: error: ‘PyTypeObject’ {aka ‘struct _typeobject’} has no member named ‘tp_print’
     6111 |   __pyx_type_14netfilterqueue_Packet.tp_print = 0;
          |                                     ^
    netfilterqueue.c:6116:45: error: ‘PyTypeObject’ {aka ‘struct _typeobject’} has no member named ‘tp_print’
     6116 |   __pyx_type_14netfilterqueue_NetfilterQueue.tp_print = 0;
          |                                             ^
    netfilterqueue.c: In function ‘__Pyx_ParseOptionalKeywords’:
    netfilterqueue.c:7076:21: warning: ‘_PyUnicode_get_wstr_length’ is deprecated [-Wdeprecated-declarations]
     7076 |                     (PyUnicode_GET_SIZE(**name) != PyUnicode_GET_SIZE(key)) ? 1 :
          |                     ^
    In file included from /usr/include/python3.9/unicodeobject.h:1026,
                     from /usr/include/python3.9/Python.h:93,
                     from netfilterqueue.c:4:
    /usr/include/python3.9/cpython/unicodeobject.h:446:26: note: declared here
      446 | static inline Py_ssize_t _PyUnicode_get_wstr_length(PyObject *op) {
          |                          ^~~~~~~~~~~~~~~~~~~~~~~~~~
    netfilterqueue.c:7076:21: warning: ‘PyUnicode_AsUnicode’ is deprecated [-Wdeprecated-declarations]
     7076 |                     (PyUnicode_GET_SIZE(**name) != PyUnicode_GET_SIZE(key)) ? 1 :
          |                     ^
    In file included from /usr/include/python3.9/unicodeobject.h:1026,
                     from /usr/include/python3.9/Python.h:93,
                     from netfilterqueue.c:4:
    /usr/include/python3.9/cpython/unicodeobject.h:580:45: note: declared here
      580 | Py_DEPRECATED(3.3) PyAPI_FUNC(Py_UNICODE *) PyUnicode_AsUnicode(
          |                                             ^~~~~~~~~~~~~~~~~~~
    netfilterqueue.c:7076:21: warning: ‘_PyUnicode_get_wstr_length’ is deprecated [-Wdeprecated-declarations]
     7076 |                     (PyUnicode_GET_SIZE(**name) != PyUnicode_GET_SIZE(key)) ? 1 :
          |                     ^
    In file included from /usr/include/python3.9/unicodeobject.h:1026,
                     from /usr/include/python3.9/Python.h:93,
                     from netfilterqueue.c:4:
    /usr/include/python3.9/cpython/unicodeobject.h:446:26: note: declared here
      446 | static inline Py_ssize_t _PyUnicode_get_wstr_length(PyObject *op) {
          |                          ^~~~~~~~~~~~~~~~~~~~~~~~~~
    netfilterqueue.c:7076:21: warning: ‘_PyUnicode_get_wstr_length’ is deprecated [-Wdeprecated-declarations]
     7076 |                     (PyUnicode_GET_SIZE(**name) != PyUnicode_GET_SIZE(key)) ? 1 :
          |                     ^
    In file included from /usr/include/python3.9/unicodeobject.h:1026,
                     from /usr/include/python3.9/Python.h:93,
                     from netfilterqueue.c:4:
    /usr/include/python3.9/cpython/unicodeobject.h:446:26: note: declared here
      446 | static inline Py_ssize_t _PyUnicode_get_wstr_length(PyObject *op) {
          |                          ^~~~~~~~~~~~~~~~~~~~~~~~~~
    netfilterqueue.c:7076:21: warning: ‘PyUnicode_AsUnicode’ is deprecated [-Wdeprecated-declarations]
     7076 |                     (PyUnicode_GET_SIZE(**name) != PyUnicode_GET_SIZE(key)) ? 1 :
          |                     ^
    In file included from /usr/include/python3.9/unicodeobject.h:1026,
                     from /usr/include/python3.9/Python.h:93,
                     from netfilterqueue.c:4:
    /usr/include/python3.9/cpython/unicodeobject.h:580:45: note: declared here
      580 | Py_DEPRECATED(3.3) PyAPI_FUNC(Py_UNICODE *) PyUnicode_AsUnicode(
          |                                             ^~~~~~~~~~~~~~~~~~~
    netfilterqueue.c:7076:21: warning: ‘_PyUnicode_get_wstr_length’ is deprecated [-Wdeprecated-declarations]
     7076 |                     (PyUnicode_GET_SIZE(**name) != PyUnicode_GET_SIZE(key)) ? 1 :
          |                     ^
    In file included from /usr/include/python3.9/unicodeobject.h:1026,
                     from /usr/include/python3.9/Python.h:93,
                     from netfilterqueue.c:4:
    /usr/include/python3.9/cpython/unicodeobject.h:446:26: note: declared here
      446 | static inline Py_ssize_t _PyUnicode_get_wstr_length(PyObject *op) {
          |                          ^~~~~~~~~~~~~~~~~~~~~~~~~~
    netfilterqueue.c:7092:25: warning: ‘_PyUnicode_get_wstr_length’ is deprecated [-Wdeprecated-declarations]
     7092 |                         (PyUnicode_GET_SIZE(**argname) != PyUnicode_GET_SIZE(key)) ? 1 :
          |                         ^
    In file included from /usr/include/python3.9/unicodeobject.h:1026,
                     from /usr/include/python3.9/Python.h:93,
                     from netfilterqueue.c:4:
    /usr/include/python3.9/cpython/unicodeobject.h:446:26: note: declared here
      446 | static inline Py_ssize_t _PyUnicode_get_wstr_length(PyObject *op) {
          |                          ^~~~~~~~~~~~~~~~~~~~~~~~~~
    netfilterqueue.c:7092:25: warning: ‘PyUnicode_AsUnicode’ is deprecated [-Wdeprecated-declarations]
     7092 |                         (PyUnicode_GET_SIZE(**argname) != PyUnicode_GET_SIZE(key)) ? 1 :
          |                         ^
    In file included from /usr/include/python3.9/unicodeobject.h:1026,
                     from /usr/include/python3.9/Python.h:93,
                     from netfilterqueue.c:4:
    /usr/include/python3.9/cpython/unicodeobject.h:580:45: note: declared here
      580 | Py_DEPRECATED(3.3) PyAPI_FUNC(Py_UNICODE *) PyUnicode_AsUnicode(
          |                                             ^~~~~~~~~~~~~~~~~~~
    netfilterqueue.c:7092:25: warning: ‘_PyUnicode_get_wstr_length’ is deprecated [-Wdeprecated-declarations]
     7092 |                         (PyUnicode_GET_SIZE(**argname) != PyUnicode_GET_SIZE(key)) ? 1 :
          |                         ^
    In file included from /usr/include/python3.9/unicodeobject.h:1026,
                     from /usr/include/python3.9/Python.h:93,
                     from netfilterqueue.c:4:
    /usr/include/python3.9/cpython/unicodeobject.h:446:26: note: declared here
      446 | static inline Py_ssize_t _PyUnicode_get_wstr_length(PyObject *op) {
          |                          ^~~~~~~~~~~~~~~~~~~~~~~~~~
    netfilterqueue.c:7092:25: warning: ‘_PyUnicode_get_wstr_length’ is deprecated [-Wdeprecated-declarations]
     7092 |                         (PyUnicode_GET_SIZE(**argname) != PyUnicode_GET_SIZE(key)) ? 1 :
          |                         ^
    In file included from /usr/include/python3.9/unicodeobject.h:1026,
                     from /usr/include/python3.9/Python.h:93,
                     from netfilterqueue.c:4:
    /usr/include/python3.9/cpython/unicodeobject.h:446:26: note: declared here
      446 | static inline Py_ssize_t _PyUnicode_get_wstr_length(PyObject *op) {
          |                          ^~~~~~~~~~~~~~~~~~~~~~~~~~
    netfilterqueue.c:7092:25: warning: ‘PyUnicode_AsUnicode’ is deprecated [-Wdeprecated-declarations]
     7092 |                         (PyUnicode_GET_SIZE(**argname) != PyUnicode_GET_SIZE(key)) ? 1 :
          |                         ^
    In file included from /usr/include/python3.9/unicodeobject.h:1026,
                     from /usr/include/python3.9/Python.h:93,
                     from netfilterqueue.c:4:
    /usr/include/python3.9/cpython/unicodeobject.h:580:45: note: declared here
      580 | Py_DEPRECATED(3.3) PyAPI_FUNC(Py_UNICODE *) PyUnicode_AsUnicode(
          |                                             ^~~~~~~~~~~~~~~~~~~
    netfilterqueue.c:7092:25: warning: ‘_PyUnicode_get_wstr_length’ is deprecated [-Wdeprecated-declarations]
     7092 |                         (PyUnicode_GET_SIZE(**argname) != PyUnicode_GET_SIZE(key)) ? 1 :
          |                         ^
    In file included from /usr/include/python3.9/unicodeobject.h:1026,
                     from /usr/include/python3.9/Python.h:93,
                     from netfilterqueue.c:4:
    /usr/include/python3.9/cpython/unicodeobject.h:446:26: note: declared here
      446 | static inline Py_ssize_t _PyUnicode_get_wstr_length(PyObject *op) {
          |                          ^~~~~~~~~~~~~~~~~~~~~~~~~~
    error: command '/usr/bin/x86_64-linux-gnu-gcc' failed with exit code 1
    ----------------------------------------
ERROR: Command errored out with exit status 1: /usr/bin/python3 -u -c 'import sys, setuptools, tokenize; sys.argv[0] = '"'"'/tmp/pip-req-build-ltdpna35/setup.py'"'"'; __file__='"'"'/tmp/pip-req-build-ltdpna35/setup.py'"'"';f=getattr(tokenize, '"'"'open'"'"', open)(__file__);code=f.read().replace('"'"'\r\n'"'"', '"'"'\n'"'"');f.close();exec(compile(code, __file__, '"'"'exec'"'"'))' install --record /tmp/pip-record-vncvx8bc/install-record.txt --single-version-externally-managed --compile --install-headers /usr/local/include/python3.9/NetfilterQueue Check the logs for full command output.

I face this error when i try to install netfilterqueue.当我尝试安装 netfilterqueue 时,我遇到了这个错误。 my python version is 2.7.18.. So if anyone know about the above error please give the solution.我的 python 版本是 2.7.18 .. 所以如果有人知道上述错误,请给出解决方案。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM