Search code examples
installationerror-handlingpip

error when trying to download ''pip install pcapy''


I want to install pcapy using "pip install pcapy but keep getting this error:

Collecting pcapy
  Using cached pcapy-0.11.4.tar.gz (37 kB)
  Preparing metadata (setup.py) ... error
  error: subprocess-exited-with-error
  
  × python setup.py egg_info did not run successfully.
  │ exit code: 1
  ╰─> [7 lines of output]
      Traceback (most recent call last):
        File "<string>", line 2, in <module>
        File "<pip-setuptools-caller>", line 34, in <module>
        File "/private/var/folders/q_/sgpdqy3d3wj_w3s3jfctw14r0000gn/T/pip-install-xxth8wkc/pcapy_ad5b43f8a92c48fe80e1260f891552a3/setup.py", line 49, in <module>
          save_init_posix = sysconfig._init_posix
                            ^^^^^^^^^^^^^^^^^^^^^
      AttributeError: module 'distutils.sysconfig' has no attribute '_init_posix'
      [end of output]
  
  note: This error originates from a subprocess, and is likely not a problem with pip.
error: metadata-generation-failed

× Encountered error while generating package metadata.
╰─> See above for output.

updated wheel and pip according to this document https://sebhastian.com/error-metadata-generation-failed/

running Python 3.11.5


Solution

  • This is an open issue in a no longer maintained package. What you can do is look at other python bindings for libpcap like pcapyplus which claims to be a maintained version of pycapy:

    Pcapyplus is a maintained fork of the no longer maintained pcapy by CORE Security Technologies available at:

    https://github.com/helpsystems/pcapy

    (from pypi)