How to solve error : command 'x86_64-linux-gnu-gcc' failed with exit status 1
(Photo from Kali)
I'm learning ethical hacking and practicing in Kali, Maybe you're doing the same or maybe you're just trying Linux. While installing a package (netfilterqueue in my case) you encountered this error, How do you go around solving it?
Let me tell you how I solved it.
You followed the steps you use when installing a package:
- Open Terminal and type
pip install netfilterqueue
for Python 2
pip3 install netfilterqueue
for Python 3
and you receive the following error:
Collecting netfilterqueue
Using cached NetfilterQueue-0.8.1.tar.gz (58 kB)
Using legacy 'setup.py install' for netfilterqueue, since package 'wheel' is not installed.
Installing collected packages: netfilterqueue
Running setup.py install for netfilterqueue: started
Running setup.py install for netfilterqueue: finished with status 'error'
DEPRECATION: The -b/--build/--build-dir/--build-directory option is deprecated. pip 20.3 will remove support for this functionality. A possible replacement is use the TMPDIR/TEMP/TMP environment variable, possibly combined with --no-clean. You can find discussion regarding this at https://github.com/pypa/pip/issues/8333.
ERROR: Command errored out with exit status 1:
command: /root/PycharmProjects/net_cut/venv/bin/python -u -c 'import sys, setuptools, tokenize; sys.argv[0] = '"'"'/tmp/pycharm-packaging/netfilterqueue/setup.py'"'"'; __file__='"'"'/tmp/pycharm-packaging/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-nzfnyzkz/install-record.txt --single-version-externally-managed --compile --install-headers /root/PycharmProjects/net_cut/venv/include/site/python3.8/netfilterqueue
cwd: /tmp/pycharm-packaging/netfilterqueue/
Complete output (114 lines):
running install
running build
running build_ext
building 'netfilterqueue' extension
creating build
creating build/temp.linux-x86_64-3.8
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/root/PycharmProjects/net_cut/venv/include -I/usr/include/python3.8 -c netfilterqueue.c -o build/temp.linux-x86_64-3.8/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 ‘PyInit_netfilterqueue’:
netfilterqueue.c:6111:3: warning: ‘tp_print’ is deprecated [-Wdeprecated-declarations]
6111 | __pyx_type_14netfilterqueue_Packet.tp_print = 0;
| ^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
In file included from /usr/include/python3.8/object.h:746,
from /usr/include/python3.8/pytime.h:6,
from /usr/include/python3.8/Python.h:85,
from netfilterqueue.c:4:
/usr/include/python3.8/cpython/object.h:260:30: note: declared here
260 | Py_DEPRECATED(3.8) int (*tp_print)(PyObject *, FILE *, int);
| ^~~~~~~~
netfilterqueue.c:6116:3: warning: ‘tp_print’ is deprecated [-Wdeprecated-declarations]
6116 | __pyx_type_14netfilterqueue_NetfilterQueue.tp_print = 0;
| ^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
In file included from /usr/include/python3.8/object.h:746,
from /usr/include/python3.8/pytime.h:6,
from /usr/include/python3.8/Python.h:85,
from netfilterqueue.c:4:
/usr/include/python3.8/cpython/object.h:260:30: note: declared here
260 | Py_DEPRECATED(3.8) int (*tp_print)(PyObject *, FILE *, int);
| ^~~~~~~~
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
----------------------------------------
ERROR: Command errored out with exit status 1: /root/PycharmProjects/net_cut/venv/bin/python -u -c 'import sys, setuptools, tokenize; sys.argv[0] = '"'"'/tmp/pycharm-packaging/netfilterqueue/setup.py'"'"'; __file__='"'"'/tmp/pycharm-packaging/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-nzfnyzkz/install-record.txt --single-version-externally-managed --compile --install-headers /root/PycharmProjects/net_cut/venv/include/site/python3.8/netfilterqueue Check the logs for full command output.
The error is quite long and I've included the entire error message so you could understand what went wrong.
A very important skill to have as a programmer is the ability to read errors. Solving errors is equally important but I think being able to identify errors takes precedence here.
The solution lies within the error. If you're able to read the error you'll be able to find what caused it and debug it quicker and more efficiently.
In our case, you notice it says Using legacy 'setup.py install' for netfilterqueue, since package 'wheel' is not installed.
and it continues installing the package.
1st thing to note down is that your system is missing the wheel
package.
Wheels are the newer standard of Python distribution. It replaces eggs.
You can read more about it here and how it compares with eggs here.
So you need to install wheels if pip is still not able to install using legacy 'setup.py'
You can install wheels using the command
pip install wheel
for Python 2 and
pip3 install wheel
for Python 3
After wheel is installed you can try to install the package again.
pip install netfilterqueue
for Python 2 and
pip3 install netfilterqueue
for Python 3
If it is able to install the package then Congratulations! You did a great job!
If however, it is not then keep reading:
Wheels did not work for you, you should read what the next error is.
It says
DEPRECATION: The -b/--build/--build-dir/--build-directory option is deprecated. pip 20.3 will remove support for this functionality. A possible replacement is use the TMPDIR/TEMP/TMP environment variable, possibly combined with --no-clean. You can find discussion regarding this at https://github.com/pypa/pip/issues/8333.
which basically means --build
is deprecated and if you read through the discussion it says the deprecation was eventually reversed so that ideally shouldn't cause an issue. But if the command still fails then you can go to netfilterqueue
Github page, to check it's installation steps.
You can just clone the directory to your local system and run setup to install the package.
You especially need to make sure you have ibnetfilter_queue
development files and its associated dependencies.
You can easily install/upgrade these using the command
apt-get install build-essential python-dev libnetfilter-queue-dev
Once done, You can now begin to clone the directory using the command
pip3 install -U git+https://github.com/kti/python-netfilterqueue
This command will clone and run the setup file as well.
If you however would like to do all the steps manually then you can use the following commands:
git clone https://github.com/kti/python-netfilterqueue.git
This command will clone the remote directory from Github to your local system.cd python-netfilterqueue
To go to the folder where it is cloned.python setup.py install
To run the setup that installs netfilterqueue in your system.
If you get an error like the below after 1st step like I did:
Then that means you do not have (lib)curl-devel
installed. This means that git
could not find the git-remote-http
executable in the executables directory.
You can run the following command to resolve that:
apt-get install libcurl4-openssl-dev
If still however git is not recognizing the remote helper for https, you can use the following command:
pip install -U git+git://github.com/kti/python-netfilterqueue
for Python 2
pip3 install -U git+git://github.com/kti/python-netfilterqueue
for Python 3
Just replace https
with git
and it should work.
After this long arduous process you should have successfully installed the package on your local system.
Take some time out and appreciate your hard work, you did a great job!
Let me know in the comments below which of these solutions worked for you
Hope you enjoyed this post! If you happen to like it, feel free to share. You can also follow me on Twitter on my coding journey.