ldx / python-iptables

Python bindings for iptables
730 stars 182 forks source link

Installing python-iptables on Centos 7 #304

Closed MichaelSweikata closed 4 years ago

MichaelSweikata commented 4 years ago

When I'm attempting to install python-iptables in a venv or on the server itself, I keep running into this error:

Running setup.py install for python-iptables ... error ERROR: Command errored out with exit status 1: command: /home/ec2-user/python3-virtualenv/bin/python3 -u -c 'import sys, setuptools, tokenize; sys.argv[0] = '"'"'/tmp/pip-install-1ibysrvd/python-iptables/setup.py'"'"'; file='"'"'/tmp/pip-install-1ibysrvd/python-iptables/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-6emx_wf2/install-record.txt --single-version-externally-managed --compile --install-headers /home/ec2-user/python3-virtualenv/include/site/python3.7/python-iptables cwd: /tmp/pip-install-1ibysrvd/python-iptables/ Complete output (23 lines): running install running build running build_py creating build creating build/lib.linux-x86_64-3.7 creating build/lib.linux-x86_64-3.7/iptc copying iptc/easy.py -> build/lib.linux-x86_64-3.7/iptc copying iptc/util.py -> build/lib.linux-x86_64-3.7/iptc copying iptc/version.py -> build/lib.linux-x86_64-3.7/iptc copying iptc/errors.py -> build/lib.linux-x86_64-3.7/iptc copying iptc/xtables.py -> build/lib.linux-x86_64-3.7/iptc copying iptc/ip4tc.py -> build/lib.linux-x86_64-3.7/iptc copying iptc/init.py -> build/lib.linux-x86_64-3.7/iptc copying iptc/ip6tc.py -> build/lib.linux-x86_64-3.7/iptc running build_ext building 'libxtwrapper' extension creating build/temp.linux-x86_64-3.7 creating build/temp.linux-x86_64-3.7/libxtwrapper gcc -pthread -Wno-unused-result -Wsign-compare -DNDEBUG -O2 -g -pipe -Wall -Wp,-D_FORTIFY_SOURCE=2 -fexceptions -fstack-protector-strong --param=ssp-buffer-size=4 -grecord-gcc-switches -m64 -mtune=generic -D_GNU_SOURCE -fPIC -fwrapv -fPIC -I/home/ec2-user/python3-virtualenv/include -I/usr/include/python3.7m -c libxtwrapper/wrapper.c -o build/temp.linux-x86_64-3.7/libxtwrapper/wrapper.o gcc -pthread -shared -Wl,-z,relro -g build/temp.linux-x86_64-3.7/libxtwrapper/wrapper.o -L/usr/lib64 -lpython3.7m -o build/lib.linux-x86_64-3.7/libxtwrapper.cpython-37m-x86_64-linux-gnu.so /usr/bin/ld: cannot find -lpython3.7m collect2: error: ld returned 1 exit status error: command 'gcc' failed with exit status 1

ERROR: Command errored out with exit status 1: /home/ec2-user/python3-virtualenv/bin/python3 -u -c 'import sys, setuptools, tokenize; sys.argv[0] = '"'"'/tmp/pip-install-1ibysrvd/python-iptables/setup.py'"'"'; file='"'"'/tmp/pip-install-1ibysrvd/python-iptables/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-6emx_wf2/install-record.txt --single-version-externally-managed --compile --install-headers /home/ec2-user/python3-virtualenv/include/site/python3.7/python-iptables Check the logs for full command output.

python3.7 exists:

(python3-virtualenv) [user@server]$ which python3.7m /usr/bin/python3.7m

And if I try in pip3, pip, or using python3 -m pip install python-iptables, same error

Python developer tools are installed:

(python3-virtualenv) [user@server]$ pip list [...] pip 20.0.2
python-dev-tools 2020.2.5
virtualenv 20.0.10
[...]

And iptables is version v1.8.2:

(python3-virtualenv) [user@server]$ which iptables /usr/sbin/iptables (python3-virtualenv) [user@server]$ iptables -V iptables v1.8.2 (legacy)

My gut feeling tells me that I'm having an issue with the version of iptables, but I can't find a requirement list of which version python-iptables needs for iptables?

ldx commented 4 years ago

You need to install python-dev or python-devel for your Python version.

MichaelSweikata commented 4 years ago

....welp. Derp. I'm glad it was something simple, and I did check to confirm that the developer tools were there, just not...y'know, the developer version.

Anyone after me looking at this problem:

https://serverfault.com/a/715731