0

Right... I've previously had this working correctly after about two days of slamming my head off my keyboard.... However, my SSD failed and I lost all my VM's and I dont remember what I did to solve this problem.

After doing some research, I've came to the conclusion that the issue is with Pycharm and how it does dynamic imports. Allthough, like I stated previously, ive had this working previously.

I've tried using recent and old versions of Pycharm and Python to no avail.

Does anyone have any idea of how I can fix this? This seems to be a commonly asked question on Google with no clear solution.

Screenshot

from scapy.layers.l2 import ARP as ARP
from scapy.layers.l2 import Ether as Ether

This is the solution I've found thus far. However, it would be helpful if this wasn't required and scapy.all could just be used as I have previously. If I ever find a solution to this myself I will post it here.

Rochie
  • 23
  • 6
  • Hi, this sounds a lot like a duplicate of [Unresolved reference with scapy](https://stackoverflow.com/questions/45691654/unresolved-reference-with-scapy) Could you check it out? – Cukic0d Jan 08 '21 at 10:11
  • Ya, just go with individual imports; it's better practice anyways. `import *` should generally be avoided; regardless of what library you're using. With scapy, it pollutes the namespace with a massive number of irrelevant names – Carcigenicate Jan 08 '21 at 14:31

1 Answers1

0

My solution is to use VS Code and pipenv instead of Pycharm as you get all the benifits of Pycharm withouts it's issues.

  1. Install pipenv globally using sudo pip install pipenv
  2. Create a virtual enviroment using pipenv install --python 3.8 for a specific version of python
  3. Do pipenv shell to start the virtual enviroment
  4. To install scapy use pipenv install scapy
  5. Select the correct virtual enviroment using Ctrl + Shift + P when in VS Code to alter settings, search for "interpreter" and select the "Python: Select Interpreter" option and select your Pipenv enviroment
  6. Run code using python program.py in the terminal

This way you can use import scapy.all as scapy, which isn't the best for production, but it is great for testing and rapid development.

Rochie
  • 23
  • 6