OSError:[WinError 126] 找不到指定的模块(使用(pcap-ct)在python中导入pcap)。

1 人关注

我正在做一个项目,我在其中使用了 ǞǞǞ pcap-ct using python in pycharm. My code was working fine but I have to transfer my project from one device to another. Both devices are running windows 10 pro with the same version.和I am using python 3.7.3 on both devices with the same pychram version, but on the first device, my project is running fine but on the second device I am getting this error.

我是这样导入的。

import pcap
import dpkt

和错误是这样的。

    File "C:\Users\Desktop\Desktop\NetworkTraficAnalyser\ShowGraph.py", line 5, in <module>
        import pcap
    File "C:\Users\Desktop\Desktop\NetworkTraficAnalyser\venv\lib\site-packages\pcap\__init__.py", line 6, in <module>
        from ._pcap     import * ; del _pcap      # noqa
  File "C:\Users\Desktop\Desktop\NetworkTraficAnalyser\venv\lib\site-packages\pcap\_pcap.py", line 20, in <module>
    from libpcap import (DLT_NULL,   DLT_EN10MB, DLT_EN3MB,   DLT_AX25,
  File "C:\Users\Desktop\Desktop\NetworkTraficAnalyser\venv\lib\site-packages\libpcap\__init__.py", line 7, in <module>
    from ._pcap      import * ; del _pcap      # noqa
  File "C:\Users\Desktop\Desktop\NetworkTraficAnalyser\venv\lib\site-packages\libpcap\_pcap.py", line 73, in <module>
    from ._dll      import dll
  File "C:\Users\Desktop\Desktop\NetworkTraficAnalyser\venv\lib\site-packages\libpcap\_dll.py", line 10, in <module>
    raise exc
  File "C:\Users\Desktop\Desktop\NetworkTraficAnalyser\venv\lib\site-packages\libpcap\_dll.py", line 8, in <module>
    dll = DLL(DLL_PATH)
  File "C:\Users\Desktop\AppData\Local\Programs\Python\Python37\lib\ctypes\__init__.py", line 356, in __init__
    self._handle = _dlopen(self._name, mode)
OSError: [WinError 126] The specified module could not be found

我已经在我的这个目录中检查了C:\Windows\System32 我有这个文件wpcap.dll

我不知道在我的两个设备上这个文件是否相同,但它在两个设备上都存在。 我搜索过这个错误代码WinError 126和found the different question和their answers but they are because someone is importing any .dll file or using it和they use \ in path和answers are they should use / or \ instead because \ are also used in Escape sequences. But I am not using anything like this.
If pcap code is using like this I don't know. can anyone help me what is the issue和what is the solution?

python
pcap
libpcap
winpcap
Usman Ghani Mughal
Usman Ghani Mughal
发布于 2020-12-27
1 个回答
Joe
Joe
发布于 2020-12-28
已采纳
0 人赞同

问题不是出在 pcap 本身,而是出在它的一个依赖项 libpcap。由于我不能访问你的电脑,所以我不能确定是什么导致了这个问题。不过,我建议采取以下一些故障排除步骤。