Issue
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:
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. I tried to install libcap
by running pip install libcap
but I also got the same problem. How can I fix this problem?
Solution
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
As you can see there, when pip installing, setup.py will try to use winpcap as a dependency to compile pcapdumper.cc and the location is expected to be 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:. Then you just open a visual command prompt and try again pip install pcapy
.
On my case I've tried using vs2015+python3.6.x and it's been built smoothly. 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.
Answered By - BPL
0 comments:
Post a Comment
Note: Only a member of this blog may post a comment.