Python doesn't print with import scapy

869 Views Asked by At

When I enter this code:

print "hhhh"
from scapy.all import sniff
print "bbbb"

this is the output:

C:\Python27\python.exe C:/Users/Tamir/PycharmProjects/SIP/main.py
hhhh
WARNING: No route found for IPv6 destination :: (no default route?)

Process finished with exit code 0

Why doesn't the second print (of "bbbb") work? When I put the import line in a comment, or import another library, it works.

1

There are 1 best solutions below

0
On

sys.stdout is redirected to readline console. It seems not working well with pycharm in this way. Please check: "PYTONPATH\Lib\site-packages\scapy\arch\windows__init__.py"

scapy\arch\windows__init__.py

temporary solution: redirect stdout to the original one

try this:

import sys
print "hhhh"
orig_stdout = sys.stdout
from scapy.all import sniff
sys.stdout =  orig_stdout
print "bbbb"