I'm new with pyshark, and I write a sample code by searching on the tutorial
import pyshark
cap = pyshark.FileCapture("input.cap")
cap_1 = cap[0]
and then it give me an error
/Users/tingyugu/anaconda3/bin/python /Users/tingyugu/PycharmProjects/final/test.py
Traceback (most recent call last):
File "/Users/tingyugu/anaconda3/lib/python3.6/site-packages/pyshark/capture/file_capture.py", line 70, in __getitem__
next(self)
File "/Users/tingyugu/anaconda3/lib/python3.6/site-packages/pyshark/capture/file_capture.py", line 60, in __next__
packet = self._packet_generator.send(None)
StopIteration
During handling of the above exception, another exception occurred:
Traceback (most recent call last):
File "/Users/tingyugu/PycharmProjects/final/test.py", line 5, in <module>
cap_1 = cap[0]
File "/Users/tingyugu/anaconda3/lib/python3.6/site-packages/pyshark/capture/file_capture.py", line 73, in __getitem__
raise KeyError('Packet of index %d does not exist in capture' % packet_index)
KeyError: 'Packet of index 0 does not exist in capture'
I know the reason is that there is no packets in the cap, but my friend can read the file by pyshark
I use the python 3.6.0 anaconda and the pyshark is 0.3.7 in anaconda
if you are on jupyter see this issue on PyShark Repo. I had the same problem, seems like pyshark does not go well with jupyter. I'm gonna assume it might have same issues with ipython as well.
there are some pull requests like this one on their repo too as a fix but nothing merged yet.
Related
code:
import ColabTurtle.Turtle as tutel
tutel.initializeTurtle()
tutel.forward(10)
error is:
<IPython.core.display.HTML object>
Traceback (most recent call last):
File "f:\stuff\e.py", line 3, in <module>
tutel.forward(10)
File "C:\Users\U.S.E.R\AppData\Local\Programs\Python\Python311\Lib\site-packages\ColabTurtle\Turtle.py", line 174, in forward
_moveToNewPosition(ending_point)
File "C:\Users\U.S.E.R\AppData\Local\Programs\Python\Python311\Lib\site-packages\ColabTurtle\Turtle.py", line 163, in _moveToNewPosition
_updateDrawing()
File "C:\Users\U.S.E.R\AppData\Local\Programs\Python\Python311\Lib\site-packages\ColabTurtle\Turtle.py", line 144, in _updateDrawing
raise AttributeError("Display has not been initialized yet. Call initializeTurtle() before using.")
AttributeError: Display has not been initialized yet. Call initializeTurtle() before using.
basically, it tells me to use intializeturtle() before running a ColabTurtle function. Except, i did already use it.
Help.
Try to run it in Google Collab. If there will be no module ColabTurtle, you need to create a new code (+code) and write
!pip install ColabTurtle
I am trying to set up the ChirpSDK, but every time I configure and run the code, I get this error:
Traceback (most recent call last):
File "test.py", line 3, in <module>
chirp = ChirpSDK()
File "/Library/Frameworks/Python.framework/Versions/3.8/lib/python3.8/site-packages/chirpsdk/chirpsdk.py", line 395, in __init__
self.read_chirprc(block)
File "/Library/Frameworks/Python.framework/Versions/3.8/lib/python3.8/site-packages/chirpsdk/chirpsdk.py", line 501, in read_chirprc
raise IOError('Could not find a ~/.chirprc file')
OSError: Could not find a ~/.chirprc file
Exception ignored in: <function ChirpSDK.__del__ at 0x10fa31af0>
Traceback (most recent call last):
File "/Library/Frameworks/Python.framework/Versions/3.8/lib/python3.8/site-packages/chirpsdk/chirpsdk.py", line 422, in __del__
self.close()
File "/Library/Frameworks/Python.framework/Versions/3.8/lib/python3.8/site-packages/chirpsdk/chirpsdk.py", line 470, in close
if self._sdk:
AttributeError: 'ChirpSDK' object has no attribute '_sdk'
I realize that the error is saying that my .chirprc file is not being recognized, but I have no idea how to remedy this. I created a .chirprc file in my /Users/username/ path, and named it c.chirprc (as the Chirp getting started article suggests), but I am still getting this error. Is there another part that I am missing? Am I reading the instructions wrong?
Thanks
The Chirp configuration file should be placed at /Users/<username>/.chirprc on macOS.
If you run ls -l ~/.chirprc in the terminal, do you get any results? If it displays no such file or directory then you have not created the file correctly.
Hi I'm a beginner with Python and Scapy. When I try to use sendp() on a basic Layer 2 packet, I get a traceback error.
Using Python 3.8 and the latest development version of Scapy from https://scapy.readthedocs.io/en/latest/installation.html#platform-specific-instructions
This is what I'm inputting into the Python shell:
import scapy
from scapy.all import *
a=Ether()/IP(dst="www.google.ca")/ICMP()/"Hello world"
sendp(a)
This is the error message:
Traceback (most recent call last):
File "<pyshell#3>", line 1, in <module>
sendp(a)
File "C:\Users\hoang\AppData\Local\Programs\Python\Python38-32\lib\site-packages\scapy-git_archive.dev304758016-py3.8.egg\scapy\sendrecv.py", line 336, in sendp
results = __gen_send(socket, x, inter=inter, loop=loop,
File "C:\Users\hoang\AppData\Local\Programs\Python\Python38-32\lib\site-packages\scapy-git_archive.dev304758016-py3.8.egg\scapy\sendrecv.py", line 296, in __gen_send
os.write(1, b".")
OSError: [Errno 9] Bad file descriptor
As pointed by #furas, this is indeed an issue with your console (IDLE?).
Scapy tries to display that the packet was sent, which fails.
You can always use
sendp(p, verbose=False)
To disable the logs, therefore working around the issue.
However I must say that if os.write(1, ..) was the only option back in the days, it's a bit outdated nowadays. This could probably be fixed on upstream.
I'm using nxt-python to connect to my nxt brick from my raspberry pi.
After some struggle with the python 3.2 versions of the bluetooth and usb libraries it requires i've managed to get it to connect via bluetooth and ask for a passkey. After some more struggle i found that i could type bluetooth-agent PASSKEY & (and replace PASSKEY with the passkey) in the terminal before running the python script that connects with the nxt brick and as far as i know that works fine. But now it throws an error. Connecting with USB throws a different error.
Here's the error i get with both methods (USB & BT) and debug enabled:
USB: True BT: True Fantom: False FUSB: False FBT: False
Traceback (most recent call last):
File "/usr/local/lib/python3.2/dist-packages/nxt/locator.py", line 138, in find_one_brick
if name and info[0].strip('\0') != name:
TypeError: Type str doesn't support the buffer API
Failed to connect to possible brick
Traceback (most recent call last):
File "/usr/local/lib/python3.2/dist-packages/nxt/locator.py", line 131, in find_one_brick
info = b.get_device_info()
File "/usr/local/lib/python3.2/dist-packages/nxt/brick.py", line 27, in poll
self.sock.send(ogram.bytes())
File "/usr/local/lib/python3.2/dist-packages/nxt/bluesock.py", line 57, in send
l0 = len(data.encode('utf-8')) & 0xFF
AttributeError: 'bytes' object has no attribute 'encode'
Failed to connect to possible brick
No brick was found.
Is the brick turned on?
For more diagnosing use the debug=True argument or
try the 'nxt_test' script located in /bin or ~/.local/bin
Traceback (most recent call last):
File "<stdin>", line 1, in <module>
File "/usr/local/lib/python3.2/dist-packages/nxt/locator.py", line 154, in find_one_brick
raise BrickNotFoundError
nxt.locator.BrickNotFoundError
Because i know python i could probably fix the errors by just editing the source code, but i'm affraid i'll break something. I've tried editing it (keeping backups of every file i edit) and then it gets past a couple of lines before throwing another different error.
EDIT
When i try to import using python 2 it gives me this error:
Traceback (most recent call last):
File "<stdin>", line 1, in <module>
File "/usr/local/lib/python2.7/dist-packages/nxt/__init__.py", line 15, in <module>
from nxt.locator import find_one_brick, Method
File "/usr/local/lib/python2.7/dist-packages/nxt/locator.py", line 49
if not silent: print("USB module unavailable, not searching there", file=sys.stderr)
^
SyntaxError: invalid syntax
I've downloaded the v2.2.2 stable instead of cloning the master commit and it runs fine under python2. Too bad it isn't python3 though.
Several times I've seen mention that for asynchronous ping is good to use twisted.
I written implementation on threads (like Ping a site in Python?)
But on ~200 threads i have crush
On page http://twistedmatrix.com/trac/wiki/ProjectsUsingTwisted i find
txNetTools - Ping, traceroute, icmp, etc., implemented in Twisted, and a library for those who want to build their own network tools.
Has anyone used this library?
I tried to use it ping.py:
Traceback (most recent call last):
File "ping.py", line 23, in <module>
class Pinger(ICMP):
NameError: name 'ICMP' is not defined
if change:
class Pinger(**ICMP**):
to
class Pinger():
Traceback (most recent call last):
File "ping.py", line 54, in <module>
reactor.listenICMP(0, Pinger())
File "./txnet/reactor.py", line 21, in listenICMP
p.startListening()
File "/usr/local/lib/python2.7/dist-packages/twisted/internet/udp.py", line 102, in startListening
self._connectToProtocol()
File "/usr/local/lib/python2.7/dist-packages/twisted/internet/udp.py", line 123, in _connectToProtocol
self.protocol.makeConnection(self)
AttributeError: Pinger instance has no attribute 'makeConnection'
Maybe I'm doing something wrong or not understand?
P.S. twisted 12.0
If you are running sandbox/ping.py, then the exception you report doesn't make sense. That file has this import near the beginning:
from txnet.icmp import ICMP, Packet, ECHO_REQUEST
This defines the ICMP name. The Pinger class comes later, extending it. I can successfully run this demo program (though it fails with an unrecognized message type when handling the response on my sytem).
Perhaps you have an old version of the code, or have modified it somehow, or are running a different ping.py?