简体   繁体   English

如何在Mac OS X上安装Python libpcap模块

[英]How to install Python libpcap module on Mac OS X

I started to work on a python sniffer project. 我开始从事python嗅探器项目的工作。 I want to use the pcap module but my computer always says "No module named pcap". 我想使用pcap模块,但是我的计算机始终显示“没有名为pcap的模块”。 I read that libpcap and pcap come with OS X but actually, it doesn't work... 我读到OS X附带了libpcap和pcap,但实际上,它不起作用...

I made a lot of research on the web and still unable tu run my python code. 我在网络上进行了大量研究,但仍然无法运行我的python代码。 How am I supposed to do for running / linking or installing pcap ? 我应该如何运行/链接或安装pcap?

Note that I recently update to OSX Yosemite (but I didn't know if pcap worked before). 请注意,我最近更新到了OSX Yosemite(但我不知道pcap以前是否起作用)。

  1. Install brew from here 这里安装brew
  2. Run brew doctor from terminal 从终端运行brew doctor
  3. Solve the warnings from brew doctor results 解决brew doctor结果中的警告
  4. Run sudo easy_install pyrex 运行sudo easy_install pyrex
  5. Run sudo easy_install pypcap 运行sudo easy_install pypcap

=> This solved my problem (don't really know if brew is necessary) =>这解决了我的问题(不知道是否需要冲泡)

I think the library libpcap exists on OS X, but you are looking for a python module to which wraps it. 我认为libpcap 库存在于OS X上,但是您正在寻找将其包装的python模块。 I think the one you want is actually called pypcap , although I have no idea if that's the right/best one(*). 我认为您想要的实际上是pypcap ,尽管我不知道那是不是正确/最好的那个(*)。 You should be able to install it with either 您应该可以通过以下任一方式安装它

easy_install pypcap

or 要么

pip install pypcap

depending on the details of your python installation. 取决于您的python安装的详细信息。 (You also need to make sure that pip and/or easy_install are installing in a place known to the python installation that you're using; this may depend on which python it is -- Apple's, python.org, brew, etc. -- and how you've set it up.) (您还需要确保将pip和/或easy_install安装在您正在使用的python安装已知的位置;这可能取决于它是哪个python-Apple,python.org,brew等。- -以及如何设置。)

(*) I don't even know what pcap does, so note that there are a lot of pcap-related modules listed on PyPi . (*)我什至不知道pcap的作用,因此请注意PyPi上列出了很多与pcap相关的模块。

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

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM