'pynput module won't run and it gives me an error that I don't understand

This is my first time using the pynput module in python, as I run my code it gives me an error that tells me to make sure that I have an "X server running". what does it mean?

Here's the code:

from pynput.mouse import Controller


#x, y are the pixels, top left is (0, 0)
def control_mouse():
    mouse = Controller()
    mouse.position = (10, 20)


control_mouse()

Here's the error output:

Traceback (most recent call last):
  File "/home/user1/PycharmProjects/pythonProject/problemsolving.py", line 1, in <module>
    from pynput.mouse import Controller
  File "/usr/local/lib/python3.8/dist-packages/pynput/__init__.py", line 40, in <module>
    from . import keyboard
  File "/usr/local/lib/python3.8/dist-packages/pynput/keyboard/__init__.py", line 31, in <module>
    backend = backend(__name__)
  File "/usr/local/lib/python3.8/dist-packages/pynput/_util/__init__.py", line 76, in backend
    raise ImportError('this platform is not supported: {}'.format(
ImportError: this platform is not supported: ('failed to acquire X connection: Can\'t connect to display ":0.0": b\'No protocol specified\\n\'', DisplayConnectionError(':0.0', b'No protocol specified\n'))

Try one of the following resolutions:

 * Please make sure that you have an X server running, and that the DISPLAY environment variable is set correctly

Process finished with exit code 1


Sources

This article follows the attribution requirements of Stack Overflow and is licensed under CC BY-SA 3.0.

Source: Stack Overflow

Solution Source