32

I have recently taken up learning networks, and I want to install scapy. I have downloaded the latest version (2.2.0), and have two versions of python on my computer- 2.6.1 and 3.3.2. My OS is windows 7 64 bit.

After extracting scapy and navigating to the correct folder in the terminal, I was instructed to run "python setup.py install". I get the following error-

File "setup.py", line 35
os.chmod(fname,0755)
................................^
......................invalid token

(dots for alignment)

How do I solve this problem?

erip
  • 16,374
  • 11
  • 66
  • 121
mikibest2
  • 508
  • 1
  • 4
  • 9

5 Answers5

51

Update: scapy-python3 is deprecated (2018) and will no longer be updated. scapy>=2.4.0 has merged python 3 compatibility.

The most up-to-date installation method is now

pip3 install scapy>=2.4.0

You may check the installation page in the documentation for other installation methods

Original answer:

Perhaps you are trying to install the package scapy for Python 2, but you need the one for Python 3.

pip install scapy 

gave this error:

os.chmod(fname,0755)
                  ^
SyntaxError: invalid token

while

pip3 install scapy-python3

did a proper install.

This error means the octal number is not recognized by Python 3, see PEP 3127:

octal literals must now be specified with a leading "0o" or "0O" instead of "0";

Cukic0d
  • 5,111
  • 2
  • 19
  • 48
galath
  • 5,717
  • 10
  • 29
  • 41
  • I'm using `pip` in a Python 3 virtualenv and still get this error; even using `pip3` gives me this. – detly Aug 28 '16 at 08:36
  • FYI. I got a "failed with error code 1 in /tmp/pip-build-yoan66gu/scapy-python3/" with runnign the pip3 install scapy-python3 – onxx Apr 02 '17 at 01:28
  • `pip3 install scapy-python3` works fine, thanks.This is not addressed in the documentation, unfortunately. – WoJ Feb 02 '18 at 07:29
9

The following works for me on Python 3.5

pip3.5 install scapy-python3
yarbs
  • 91
  • 1
  • 1
4

Change os.chmod(fname,0755) to os.chmod(fname,0o755) and re-run

0

If pip installation is causing problem. You can download using wget and try to install.

$ cd /tmp
$ wget --trust-server-names scapy.net
$ unzip scapy-x.x.x.zip
$ cd scapy
$ sudo python setup.py install

Check here for all ways of installing scapy.

rashok
  • 12,790
  • 16
  • 88
  • 100
-2

Scapy mainly used on uinx-liked OS, and can't install by pip. But they offered msi installer for windows:

http://www.secdev.org/projects/scapy/doc/installation.html

The error also occurs on Linux, but virtualenv saves me.Virtualenv is a really good solution of using different version python or librarys on one OS.

virtualenv -p $python_bin_path $virtualenv_directory_name

Creating a virtual env with python2 and python3:

virtualenv -p `which python` project_with_python2
virtualenv -p `which python3` project_with_python3

Then active the env, and install the requirements.

cd project_with_python2
source bin/activate
pip install scapy
pip install -r requirements.txt

And using deactivate to exit env.

Slark
  • 255
  • 2
  • 5