Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Scapy installation fails due to invalid token

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?

like image 736
mikibest2 Avatar asked Aug 21 '15 10:08

mikibest2


3 Answers

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";

like image 89
galath Avatar answered Oct 19 '22 16:10

galath


The following works for me on Python 3.5

pip3.5 install scapy-python3
like image 9
yarbs Avatar answered Oct 19 '22 16:10

yarbs


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

like image 4
user5705810 Avatar answered Oct 19 '22 14:10

user5705810