Struggling with Python

Has anyone successfully installed the pcapy python module on SNG7? I keep getting gcc errors no matter which version of python or pip that I install. I have followed the below links to no avail.

python 3.4 - How to install pip in CentOS 7? - Stack Overflow

Pip3 in FreePBX v16? - Distro Discussion & Help - FreePBX Community Forums

‘pcapdumper.cc:10:20: fatal error: Python.h: No such file or directory’ via pip install - English / Applications - openSUSE Forums

I can install other modules. Below is the error when installing pcapy:

[root@freepbx ~]# pip3 install pcapy
Collecting pcapy
  Using cached pcapy-0.11.4.tar.gz (37 kB)
  Preparing metadata (setup.py) ... done
Using legacy 'setup.py install' for pcapy, since package 'wheel' is not installed.
Installing collected packages: pcapy
    Running setup.py install for pcapy ... error
    ERROR: Command errored out with exit status 1:
     command: /bin/python3 -u -c 'import io, os, sys, setuptools, tokenize; sys.argv[0] = '"'"'/tmp/pip-install-ai481zmw/pcapy_b1e7c54faae64896b06810723fe94320/setup.py'"'"'; __file__='"'"'/tmp/pip-install-ai481zmw/pcapy_b1e7c54faae64896b06810723fe94320/setup.py'"'"';f = getattr(tokenize, '"'"'open'"'"', open)(__file__) if os.path.exists(__file__) else io.StringIO('"'"'from setuptools import setup; setup()'"'"');code = f.read().replace('"'"'\r\n'"'"', '"'"'\n'"'"');f.close();exec(compile(code, __file__, '"'"'exec'"'"'))' install --record /tmp/pip-record-r41gd9b8/install-record.txt --single-version-externally-managed --compile --install-headers /usr/include/python3.6m/pcapy
         cwd: /tmp/pip-install-ai481zmw/pcapy_b1e7c54faae64896b06810723fe94320/
    Complete output (12 lines):
    running install
    running build
    running build_ext
    building 'pcapy' extension
    creating build
    creating build/temp.linux-x86_64-3.6
    gcc -pthread -Wno-unused-result -Wsign-compare -DDYNAMIC_ANNOTATIONS_ENABLED=1 -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/usr/include/python3.6m -c pcapdumper.cc -o build/temp.linux-x86_64-3.6/pcapdumper.o
    pcapdumper.cc:10:20: fatal error: Python.h: No such file or directory
     #include <Python.h>
                        ^
    compilation terminated.
    error: command 'gcc' failed with exit status 1
    ----------------------------------------
ERROR: Command errored out with exit status 1: /bin/python3 -u -c 'import io, os, sys, setuptools, tokenize; sys.argv[0] = '"'"'/tmp/pip-install-ai481zmw/pcapy_b1e7c54faae64896b06810723fe94320/setup.py'"'"'; __file__='"'"'/tmp/pip-install-ai481zmw/pcapy_b1e7c54faae64896b06810723fe94320/setup.py'"'"';f = getattr(tokenize, '"'"'open'"'"', open)(__file__) if os.path.exists(__file__) else io.StringIO('"'"'from setuptools import setup; setup()'"'"');code = f.read().replace('"'"'\r\n'"'"', '"'"'\n'"'"');f.close();exec(compile(code, __file__, '"'"'exec'"'"'))' install --record /tmp/pip-record-r41gd9b8/install-record.txt --single-version-externally-managed --compile --install-headers /usr/include/python3.6m/pcapy Check the logs for full command output.

I was struggling with pip3 for gTTS and the below worked for me but I see you have that cited already

Yeah other modules like dpkt install fine with pip3 just not pcapy. I am close to figuring it out and if I do I’ll post back here, just wondering if anyone had specific experience with that module.

So I have to use python 2.7 in order to get it to work. The reason I can’t get it to work with python 3 is I am missing dependency python3-devel but it won’t let me install it due to file conflicts with python3.6u. So:

yum install python-devel
yum install libpcap-devel
curl https://bootstrap.pypa.io/pip/2.7/get-pip.py --output get-pip.py
python get-pip.py
pip install pcapy

It warns about 2.7 being EOL but it seems the only way to get it to work on SNG7. I cannot remove or modify 3.6u because sangoma-pbx.noarch is a dependency.

This topic was automatically closed 31 days after the last reply. New replies are no longer allowed.