0

By running this simple code in Python

>>> from pythonping import ping
>>> ping('127.0.0.1', verbose=True)

I get this error

Traceback (most recent call last):
  File "<stdin>", line 1, in <module>
  File "/home/j0tz/.local/lib/python3.10/site-packages/pythonping/__init__.py", line 81, in ping
    comm = executor.Communicator(target, provider, timeout, interval, socket_options=options, verbose=verbose, output=out,
  File "/home/j0tz/.local/lib/python3.10/site-packages/pythonping/executor.py", line 293, in __init__
    self.socket = network.Socket(target, 'icmp', options=socket_options, source=source)
  File "/home/j0tz/.local/lib/python3.10/site-packages/pythonping/network.py", line 31, in __init__
    self.socket = socket.socket(socket.AF_INET, socket.SOCK_RAW, self.protocol)
  File "/usr/lib/python3.10/socket.py", line 232, in __init__
    _socket.socket.__init__(self, family, type, proto, fileno)
PermissionError: [Errno 1] Operation not permitted

I tried running it as sudo but to no avail. I don't know what the cause of the error is, so I'm hoping for intelligent answers from knowledgeable people.

Pythonping is a public repository I found on PyPI. In the code I try to simply ping Localhost, returning the results on the screen when I set the "verbose" parameter to True.

1 Answers1

0

you need root user permission to use it

run python3 such as root user then everything will be OK. and if you use it on a file run it with the root user.

Verfosec
  • 26
  • 4