failed when I install pypcap on Mac with Python 2.7
I need to install pypcap with Python 2 on Mac. It failed when I use source install: python2 setup.py install
pcap_ex.c:292:10: warning: 'pcap_compile_nopcap' is deprecated: use pcap_open_dead(), pcap_compile() and pcap_close() [-Wdeprecated-declarations] return (pcap_compile_nopcap(snaplen, dlt, fp, str, optimize, netmask)); ^ /usr/local/include/pcap/pcap.h:617:1: note: 'pcap_compile_nopcap' has been explicitly marked deprecated here PCAP_DEPRECATED("use pcap_open_dead(), pcap_compile() and pcap_close()") ^ /usr/local/include/pcap/funcattrs.h:307:47: note: expanded from macro 'PCAP_DEPRECATED' #define PCAP_DEPRECATED(msg) attribute((deprecated(msg))) ^ 2 warnings generated. /usr/bin/clang -bundle -undefined dynamic_lookup -arch i386 -arch x86_64 -g build/temp.macosx-10.6-intel-2.7/pcap.o build/temp.macosx-10.6-intel-2.7/pcap_ex.o -L/usr/local/lib -lpcap -o build/lib.macosx-10.6-intel-2.7/pcap.so ld: warning: The i386 architecture is deprecated for macOS (remove from the Xcode build setting: ARCHS) ld: warning: ignoring file /usr/local/lib/libpcap.dylib, missing required architecture i386 in file /usr/local/lib/libpcap.dylib (2 slices) ld: warning: ignoring file /Applications/Xcode.app/Contents/Developer/Platforms/MacOSX.platform/Developer/SDKs/MacOSX.sdk/usr/lib/libSystem.tbd, missing required architecture i386 in file /Applications/Xcode.app/Contents/Developer/Platforms/MacOSX.platform/Developer/SDKs/MacOSX.sdk/usr/lib/libSystem.tbd (3 slices) ld: dynamic main executables must link with libSystem.dylib for architecture i386 clang: error: linker command failed with exit code 1 (use -v to see invocation) error: command '/usr/bin/clang' failed with exit status 1
It also failed when I use pip install: pip2 install pypcap /usr/local/include/pcap/pcap.h:394:1: note: 'pcap_lookupdev' has been explicitly marked deprecated here PCAP_DEPRECATED("use 'pcap_findalldevs' and use the first device") ^ /usr/local/include/pcap/funcattrs.h:307:47: note: expanded from macro 'PCAP_DEPRECATED' #define PCAP_DEPRECATED(msg) attribute((deprecated(msg))) ^ pcap_ex.c:292:10: warning: 'pcap_compile_nopcap' is deprecated: use pcap_open_dead(), pcap_compile() and pcap_close() [-Wdeprecated-declarations] return (pcap_compile_nopcap(snaplen, dlt, fp, str, optimize, netmask)); ^ /usr/local/include/pcap/pcap.h:617:1: note: 'pcap_compile_nopcap' has been explicitly marked deprecated here PCAP_DEPRECATED("use pcap_open_dead(), pcap_compile() and pcap_close()") ^ /usr/local/include/pcap/funcattrs.h:307:47: note: expanded from macro 'PCAP_DEPRECATED' #define PCAP_DEPRECATED(msg) attribute((deprecated(msg))) ^ 2 warnings generated. creating build/lib.macosx-10.6-intel-2.7 /usr/bin/clang -bundle -undefined dynamic_lookup -arch i386 -arch x86_64 -g build/temp.macosx-10.6-intel-2.7/pcap.o build/temp.macosx-10.6-intel-2.7/pcap_ex.o -L/usr/local/lib -lpcap -o build/lib.macosx-10.6-intel-2.7/pcap.so ld: warning: The i386 architecture is deprecated for macOS (remove from the Xcode build setting: ARCHS) ld: warning: ignoring file /usr/local/lib/libpcap.dylib, missing required architecture i386 in file /usr/local/lib/libpcap.dylib (2 slices) ld: warning: ignoring file /Applications/Xcode.app/Contents/Developer/Platforms/MacOSX.platform/Developer/SDKs/MacOSX.sdk/usr/lib/libSystem.tbd, missing required architecture i386 in file /Applications/Xcode.app/Contents/Developer/Platforms/MacOSX.platform/Developer/SDKs/MacOSX.sdk/usr/lib/libSystem.tbd (3 slices) ld: dynamic main executables must link with libSystem.dylib for architecture i386 clang: error: linker command failed with exit code 1 (use -v to see invocation) error: command '/usr/bin/clang' failed with exit status 1
warning: 'pcap_compile_nopcap' is deprecated: use pcap_open_dead(), pcap_compile() and pcap_close()
It's deprecated because, at least in some versions of NetBSD, it has a different function signature ("different" as in "different number of arguments") from the one in libpcap and other platforms. pcap_open_dead(), pcap_compile(), and pcap_close() do not have that problem.
if pypcap can switch to using those routines if pcap_open_dead() is available, it should. If it can't, because it's directly exporting a pcap_compile_nopcap-based API, it should somehow deal with API differences in libpcap.
note: 'pcap_lookupdev' has been explicitly marked deprecated here
That one's even worse - it's not thread-safe (I guess making its static data thread-local would fix that), and, if you support Windows, it returns UTF-16 strings, at least on NT-based Windows - not ASCII/UTF-8/local code page strings - and changing that would break binary compatibility with programs using WinPcap or Npcap.
If pypcap can switch to, as the deprecation warning says, "[using] 'pcap_findalldevs' and [using] the first device", it should. If it can't, because it's directly exporting a pcap_lookupdev-based API and can't implement it atop pcap_findalldevs(), it should deprecate that API and say "watch out on Windows!"
/usr/bin/clang -bundle -undefined dynamic_lookup -arch i386 -arch x86_64 ...
That probably will not work on Catalina or later, as they don't support 32-bit binaries, meaning none of the system libraries include 32-bit x86 code.
If pypcap defaults to building universal binaries, it should not do so on Catalina, and should build x86-64/ARM64 universal binaries, not IA-32/x86-64 universal binaries, on post-Catalina releases.
If pypcap doesn't default to building universal binaries, people trying to install pypcap shouldn't do anything that would override that if they're building on Catalina or later.
(Unless the universal-binary problem is a Python 2/pip2 problem.)
My macOS is Monterey 12.6.5, It's successful with "pip2 install pypcap" on my another macOS Big Sur.
So may I try to reinstall python 2.7/pip2 on my first macOS?
I solve it, thanks also. My macOS is Monterey 12.6.5, it removes [Python 2.7]。 I download "python-2.7.14-macosx10.6.pkg" and it makes the above issue。 I uninstall the "python-2.7.14-macosx10.6.pkg" and reinstall "python-2.7.18-macosx10.9.pkg" then it works. (Reference to https://apple.stackexchange.com/questions/438427/restore-python-2-7-on-monterey-12-3)
pip2 install pypcap DEPRECATION: Python 2.7 will reach the end of its life on January 1st, 2020. Please upgrade your Python as Python 2.7 won't be maintained after that date. A future version of pip will drop support for Python 2.7. More details about Python 2 support in pip, can be found at https://pip.pypa.io/en/latest/development/release-process/#python-2-support Collecting pypcap Using cached https://files.pythonhosted.org/packages/db/4f/419ad9b163f3e86c32ae3b1e2937709520e24dce589897a26fb875189520/pypcap-1.3.0.tar.gz Installing collected packages: pypcap Running setup.py install for pypcap ... done Successfully installed pypcap-1.3.0 WARNING: You are using pip version 19.2.3, however version 20.3.4 is available. You should consider upgrading via the 'pip install --upgrade pip' command.