2

I'm trying to import the scapy module into blender:

from bge import logic
import socket
from scapy.all import *

But I face this exception:

enter image description here

I copied the scapy module folder into:

C:\Program Files\Blender Foundation\Blender\2.75\scripts\modules

And this is what it contains:

enter image description here

Notice all and base_classes is in it.

In addition i tried to add the PYTHONPATH in the environment variables (I'm not sure this is what I had to do.. I also tried to add

C:\Program Files\Blender Foundation\Blender\2.75\scripts\modules\scapy

in the PATH and in PYTHONPATH, they both didn't solve the problem):

enter image description here

EDIT:

The problem as sambler said is that I used scapy that doesn't support python 3.x as blender uses. So I download newer scapy version which supports python 3.x from here: https://github.com/phaethon/scapy and replaced it with the older scapy, now it works but I can't sniff, send or receive packets:

enter image description here

enter image description here

Maor2871
  • 147
  • 1
  • 13

2 Answers2

2

The direct cause of this error is that you don't have C:\Program Files\Blender Foundation\Blender\2.75\scripts\modules in the PYTHONPATH environment variable. It's not a specific Blender issue, it's a general Python requirement for loading third-party packages.

You can try to add PYTHONPATH as a global per-user environment variable as described in this question: How to add to the pythonpath in windows 7?

Community
  • 1
  • 1
alexanderlukanin13
  • 4,577
  • 26
  • 29
1

There are two things in the screenshot of the error that giveaway the problem -

  • the ^ in the last line is pointing at the L in 0xFFL
  • the line above that shows C:\Python27\scapy\base_classes.py

From 2.50 onwards blender uses python 3.x and the error causing the exception (L to specify a long int) is a python 2.7 language feature that was removed in 3.0.

A quick search shows a fork of scapy has been made to work with python3

Have a look at scapy-python3

sambler
  • 6,917
  • 1
  • 16
  • 23
  • Thanks!! That was the problem.. Now scapy works and i can import it Although I can't send or receive packets as I updated in the question. – Maor2871 Jan 03 '16 at 11:04
  • Should be a separate question. Have you tried to use scapy outside of blender? As mentioned in [this tutorial](http://www.secdev.org/projects/scapy/doc/usage.html) you should have admin privileges. – sambler Jan 03 '16 at 11:18