Reputation: 11
I'm trying to run this file that uses the scapy library. It doesnt recognize scapy when I run the code though:
from scapy.all import *
def arp_display(pkt):
if pkt[ARP].op == 1: #who-has (request)
if pkt[ARP].psrc == '0.0.0.0': # ARP Probe
print ("ARP Probe from: " + pkt[ARP].hwsrc)
print (sniff(prn=arp_display, filter="arp", store=0, count=10))
This is the error message:
/Library/Frameworks/Python.framework/Versions/3.5/bin/python3.5 /Users/me/PycharmProjects/AmazonDash/DashButton
Traceback (most recent call last):
File "/Users/me/PycharmProjects/AmazonDash/DashButton", line 2, in <module>
from scapy.all import *
ImportError: No module named 'scapy'
I installed homebrew and used it to download and install Scapy. I assumed that because I did that, my PyCharm would be able to run the script. I'm not so familiar with Python or PyCharm though, so which step am I missing? I also tried updating the Path in the preferences of PyCharm, pointing it to the scapy folder that was added by homebrew.
Upvotes: 1
Views: 3841
Reputation: 111
CTRL+Shift+s to bring up the settings and have a look at your python interpreter to see if scapy is there (you can also download modules directly this way too)
that's if you don't go down the virtual env route ofc
(edit) I literally just scrolled down 2 issues and found Unresolved reference with scapy
Upvotes: 0
Reputation: 1
For you to be able to use the scapy library you first must go in the preferences of your project on Pycharm . Then, in the preferences, search for the Project Interpreter and from there you will be able to add any packages existing in python that you want. Then you just have to click on the + in the bottom of the page and search for any package/library that you want to install. And now you can use any one that you need...
Upvotes: 0
Reputation: 311
For me, I found my Python3 did not include scapy, so I installed pip3, then used pip3 to install scapy:
sudo apt-get install -y python3-dev
pip3 install scapy
Then, in PyCharm, I did what @gosha-f mentioned:
PyCharm -> File -> Settings -> Project interpreter
then find the Add button +
on the right, and from there search for, and install, PyCharm's module for scapy (requires internet access).
Upvotes: 0
Reputation: 427
You probably somehow installed multiple virtualenvs .
Check File -> Settings -> project interpreter in PyCharm; it will let you select the correct python environment to use in the project, and also install packages into that particular environment.
Upvotes: 1