Win10 anaconda python3.6 install pcap

Note that for a good source when using pip or conda installation package, otherwise it is very slow. DETAILED see link set [4,5].

The Linux (physical host or virtual machine) is very easy to install pypcap package, it is omitted. Windows10 system installed on many pits, follow the steps here to do a specific explanation. WinPcap and compatibility issues Win10, it is recommended to use alternative Npcap WinPcap. Python's pcap libpcap module is packaged version of Python. Pcap download installation module requires three components are mounted.

1 ) Download

Npcap https://nmap.org/npcap/

NpcapSDK https://nmap.org/npcap/

pypcap https://github.com/pynetwork/pypcap

 

2 ) Installation

( 1 ) Installation Npcap

Open the installer. If winpcap installed before, it will first be uninstalled automatically.

 

 

( 2 ) Installation pypcap and NpcapSDK

1. NpcapSDK folder into pypcap the same level folder, the folder named wpdpack

 

 

2. Open the anaconda prompt (script automatically sets python and conda environment variables)

 

 

 

3. Go to the directory where pypcap, execute python setup.py install

  If prompted missing Visual C ++ 14.0, you need to install visual studio 2017, or just the lack of development tools.

Fixed Python3 on Windows 10 error Visual C++ 14.0 is required

(Installation of a lack of development tools need to be online to download, due to network problems, probably not been downloaded.)

 

 

 

 

4. The installation is successful, return to python environment. Test import pcap, check if you can use. No error, everything is normal, then the installation was successful.

 

note:

If you are using python3.7.2 above, it may cause the installation to fail. (See link reasons [3]). If using version python3.6 can be installed successfully.

Each packet is a virtual environment isolated from each other and independently, and therefore need to be replaced if the Python version, the package also dpkt need to reinstall the like, pycharm interpreter also needs to switch disposed inside.

To switch conda version can be used to create a virtual environment of ways. Link see [2].

 

 

 

 

 

 

 

 

 

 

 

Pycharm inside of Environmental Management:

 

 

Add path can be found:

 

 

 

Select the appropriate Conda Environment has been created. (Note that in the figure, and the same command line New environment conda create effects)

 

 

 

 

After selecting and applying the interpreter can see the new environment only dpkt, pypcap and default of several packages. The benefits of a virtual environment is installed in each environment package will not conflict with each other, played a role similar to the program namespace.

 

 

5. Test capture

Test script:

import pcap

import  dpkt

PC = PCAP . PCAP ()     # Note, the parameter may be a name of the NIC, such as eth0

PC . setFilter ( 'TCP Port 80' )     # snoop filter provided

for  ptime , pData  in  PC :     #ptime is the time of receipt, pdata to receive data

    print(ptime,pdata)    #...

 

running result:

 

Reference links

[1]   https://visualstudio.microsoft.com/downloads/

[2]   The use of Anaconda to manage multiple versions of the Python environment

[3]   realization of pypcap install Python libraries and simple packet capture tools

[. 4]   Anaconda help mirroring

[. 5]   PyPI help mirroring

Guess you like

Origin www.cnblogs.com/followyourheart/p/python_pypcap.html