Python doesn't print with import scapy

可紊 提交于 2019-12-11 03:33:24

问题


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:


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"

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"


来源:https://stackoverflow.com/questions/30812350/python-doesnt-print-with-import-scapy

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!