Open pavel-kirienko opened 3 years ago
I just discovered that the problem is, apparently, related to the PATH
configuration. Adding the DLL directory to PATH explicitly before loading the module fixes the problem:
set PATH=C:\Python39-x64\lib\site-packages\libpcap\_platform\_windows\x64\wpcap;%PATH%
python -c "import libpcap" # Success
Functional workaround:
import os
import sys
import pathlib
import importlib.util
if sys.platform.startswith('win'):
libpcap_dir = pathlib.Path(importlib.util.find_spec('libpcap').origin).parent
dll_path = libpcap_dir / '_platform' / '_windows' / ('x64' if sys.maxsize.bit_length() > 32 else 'x86') / 'wpcap'
os.environ['PATH'] += os.pathsep + str(dll_path)
import libpcap
I wouldn't venture to fix it in the upstream without @karpierz 's blessing though.
:> Has the library been tested against Windows Server? No. At all :( :> Are there any major differences in DLL handling between the desktop Windows 10 and Windows Server 2019? Should not be any difference :(
Has the library been tested against Windows Server? Are there any major differences in DLL handling between the desktop Windows 10 and Windows Server 2019? I don't have much experience with Windows so I might be missing something obvious but my problem is that while the library seems to be working on a desktop Windows 8/10 (running via VirtualBox), on a Windows Server 2019 I consistently get this:
This is reproducible with Python 3.7, 3.8, and 3.9 in a virtualized AMD64 server.
The recipe to reproduce is: