简体   繁体   English

pip install pcapy 无法打开包含文件“pcap.h”

[英]pip install pcapy cannot open include file 'pcap.h'

I tried to install pcapy using pip install pcapy , but I encoutered an error stating that the file pcap.h does not exist as following:我试图安装pcapy使用pip install pcapy ,但我encoutered一个错误,说明该文件pcap.h不存在如下:

Installing collected packages: pcapy
  Running setup.py install for pcapy ... error
    Complete output from command c:\python27\python.exe -u -c "import setuptools
tokenize;__file__='c:\\users\\username\\appdata\\local\\temp\\pip-install-1tyk
yr\\pcapy\\setup.py';f=getattr(tokenize, 'open', open)(__file__);code=f.read().replace('\r\n', '\n');f.close();exec(compile(code, __file__, 'exec'))" 
install --
record c:\users\username\appdata\local\temp\pip-record-u_q6qm\install-record.txt
 --single-version-externally-managed --compile:
    running install
    running build
    running build_ext
    building 'pcapy' extension
    creating build
    creating build\temp.win-amd64-2.7
    creating build\temp.win-amd64-2.7\Release
    creating build\temp.win-amd64-2.7\Release\win32
    C:\Users\UserName\AppData\Local\Programs\Common\Microsoft\Visual C++ for
Python\9.0\VC\Bin\amd64\cl.exe /c /nologo /Ox /MD /W3 /GS- /DNDEBUG -DWIN32=1 -I
c:\wpdpack\Include -Ic:\python27\include -Ic:\python27\PC /Tppcapdumper.cc /Fobuild\temp.win-amd64-2.7\Release\pcapdumper.obj
    pcapdumper.cc
    pcapdumper.cc(11) : fatal error C1083: Cannot open include file: 'pcap.h': N
o such file or directory
    error: command 'C:\\Users\\UserName\\AppData\\Local\\Programs\\Common\\Microsoft\\Visual C++ for Python\\9.0\\VC\\Bin\\amd64\\cl.exe' failed with exit status 2

Command "c:\python27\python.exe -u -c "import setuptools, tokenize;__file__='c:\\users\\username\\appdata\\local\\temp\\pip-install-1tykyr\\pcapy\\setup.py';f=getattr(tokenize, 'open', open)(__file__);code=f.read().replace('\r\n', '\n');f.close();exec(compile(code, __file__, 'exec'))" install --record c:\users\username\appdata\local\temp\pip-record-u_q6qm\install-record.txt --single-version-externally-managed --compile" failed with error code 1 in c:\users\username\appdata\local\temp\pip-install-1tykyr\pcapy\

I tried to upgrade setuptools but I got the same result.我尝试升级setuptools但得到了相同的结果。 I tried to install libcap by running pip install libcap but I also got the same problem.我试图通过运行pip install libcap来安装libcap ,但我也遇到了同样的问题。 How can I fix this problem?我该如何解决这个问题?

Let's take a look first to this specific line cl.exe /c /nologo /Ox /MD /W3 /GS- /DNDEBUG -DWIN32=1 -Ic:\\wpdpack\\Include -Ic:\\python27\\include -Ic:\\python27\\PC /Tppcapdumper.cc /Fobuild\\temp.win-amd64-2.7\\Release\\pcapdumper.obj我们先来看看这个具体的行cl.exe /c /nologo /Ox /MD /W3 /GS- /DNDEBUG -DWIN32=1 -Ic:\\wpdpack\\Include -Ic:\\python27\\include -Ic:\\python27\\PC /Tppcapdumper.cc /Fobuild\\temp.win-amd64-2.7\\Release\\pcapdumper.obj

As you can see there, when pip installing, setup.py will try to use winpcap as a dependency to compilepcapdumper.cc and the location is expected to be c:\\wpdpack .正如你在那里看到的,当 pip 安装时,setup.py 会尝试使用winpcap作为依赖来编译pcapdumper.cc并且位置应该是c:\\wpdpack

To make it work you just need to download and extract the latest stable winpcap library version (ie: not beta suffix) and uncompress it on c:.要使其工作,您只需要下载并提取最新的稳定的 winpcap 库版本(即:不是 beta 后缀)并在 c: 上解压缩它。 Then you just open a visual command prompt and try again pip install pcapy .然后您只需打开一个可视化命令提示符并再次尝试pip install pcapy

On my case I've tried using vs2015+python3.6.x and it's been built smoothly.在我的情况下,我尝试使用 vs2015+python3.6.x 并且它构建得很顺利。 In any case, make sure you read its docs carefully, specially the part where it talks about requirements .在任何情况下,请确保您仔细阅读它的文档,特别是它谈论需求的部分。

Also, one last hint, I recommend you take a look to this answer which explains very briefly how to proceed each time you want to install tricky libraries like this pcapy.另外,最后一个提示,我建议您看一下这个答案,它非常简要地解释了每次要安装像 pcapy 这样棘手的库时如何进行。

It's generally easier to download install a binary.下载安装二进制文件通常更容易。 If you do build from source:如果您确实从源代码构建:

Download the WinPcap Developer's Pack .下载WinPcap 开发人员包

Use pip's --global-option.使用 pip 的 --global-option。 setup.py is different, but I think pip is preferred over setup.py anyway. setup.py 是不同的,但我认为 pip 无论如何都比 setup.py 更受欢迎。

Here's an example line (substitute in the correct paths for your system; I just referenced them right in the Downloads folder):这是一个示例行(替换为您系统的正确路径;我只是在下载文件夹中引用了它们):

pip install ./pcapy-src-dir --global-option=build_ext --global-option="-LC:\path\to\WpdPack_4_1_2\WpdPack\Lib" --global-option="-IC:\path\to\WpdPack_4_1_2\WpdPack\Include 

See also this answer另请参阅此答案

暂无
暂无

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

相关问题 在Windows 7上安装pcapy时遇到问题 - 无法打开包含文件:'pcap.h' - trouble installing pcapy on windows 7 - cannot open include file: 'pcap.h' pip install hunspell:无法打开包含文件:'hunspell.h':没有这样的文件或目录 - pip install hunspell: Cannot open include file: 'hunspell.h': No such file or directory 执行`pip install mod_wsgi`时`无法打开包含文件:'apr_perms_set.h'` - `Cannot open include file: 'apr_perms_set.h'` when doing `pip install mod_wsgi` Python pip install kivy致命错误C1083:无法打开包含文件:'GL / glew.h':没有这样的文件或目录 - Python pip install kivy fatal error C1083: Cannot open include file: 'GL/glew.h': No such file or directory 无法安装 mysqlcient:无法打开包含文件:'mysql.h' - Cannot install mysqlcient: Cannot open include file: 'mysql.h' pcap pakage to python project error is pcap.h not found - pcap pakage to python project error is pcap.h not found 使用Pcapy将数据包保存到pcap文件中 - Saving packets to a pcap file using Pcapy 在 win64 上 pip install mysqlclient 无法正常工作,出现错误“无法打开文件:‘mysql.h’ - pip install mysqlclient on win64 not working giving error 'Cannot open file: 'mysql.h' Windows:pip install zbar无法打开包含文件,并以退出状态2失败 - windows: pip install zbar cannot open include file and failed with exit status 2 无法打开包含文件:“ SDL.h” - Cannot open include file: 'SDL.h'
 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM