pythonpermissionspycharmpingsuperuser

PyCharm PermissionError


I have a little problem with pycharm permission. I wanted to run my script but then appears a permission error. I used the package pythonping to ping a proxy address. I can run the script over the terminal in MacOS with the sudo command but i wanted to run everything in PyCharm.

Here is the Code:

import pythonping

pythonping.ping('47.241.107.35', verbose=True)

and this is the output:

Traceback (most recent call last):
  File "/Users/dominik/Documents/Pycharm Projects on MacOS/venv/scripts/test_pythonping.py", line 3, in <module>
    pythonping.ping('47.241.107.35', verbose=True)
  File "/Library/Frameworks/Python.framework/Versions/3.9/lib/python3.9/site-packages/pythonping/__init__.py", line 73, in ping
    comm = executor.Communicator(target, provider, timeout, socket_options=options, verbose=verbose, output=out,
  File "/Library/Frameworks/Python.framework/Versions/3.9/lib/python3.9/site-packages/pythonping/executor.py", line 247, in __init__
    self.socket = network.Socket(target, 'icmp', source=None, options=socket_options)
  File "/Library/Frameworks/Python.framework/Versions/3.9/lib/python3.9/site-packages/pythonping/network.py", line 33, in __init__
    self.socket = socket.socket(socket.AF_INET, socket.SOCK_RAW, self.protocol)
  File "/Library/Frameworks/Python.framework/Versions/3.9/lib/python3.9/socket.py", line 232, in __init__
    _socket.socket.__init__(self, family, type, proto, fileno)
PermissionError: [Errno 1] Operation not permitted

Solution

  • You can run PyCharm as an admin and then all scripts will run with admin rights.