I am trying to run PyVirtualDisplay on my raspberry pi to open up a webpage. However, when I run it, an error is thrown.
The error is as follows:
Traceback (most recent call last):
File "test.py", line 4, in <module>
from pyvirtualdisplay import Display
File "/usr/local/lib/python2.7/dist-packages/pyvirtualdisplay/__init__.py", line 4, in <module>
from pyvirtualdisplay.display import Display
File "/usr/local/lib/python2.7/dist-packages/pyvirtualdisplay/display.py", line 26
backend: Optional[str] = None,
^
SyntaxError: invalid syntax
The code that I am running is as follows:
from selenium import webdriver
from selenium.webdriver.common.by import By
from selenium.webdriver.common.keys import Keys
from pyvirtualdisplay import Display
display = Display(visible=0, size=(1600, 1200))
display.start()
driver = webdriver.Chrome()
driver.get('https://colab.research.google.com/drive/1pqGSjrP3SujtxNwoB_AgVqM0c5DI8R4q')
driver.ActionChains(driver).key_down(Keys.CONTROL).send_keys(Keys.ENTER).perform()
I am running this on my raspberry pi 3 B+, on its latest firmware. I have installed pyvirtualdisplay using pip, and also have installed xvfb.
I am not sure why the error is occurring, but it seems to be due to an error in the "display.py" file.
The relevant parts of the "display.py" file is below(the line with the error is in line 3):
def __init__(
self,
backend: Optional[str] = None,
visible: bool = False,
size: Tuple[int, int] = (1024, 768),
color_depth: int = 24,
bgcolor: str = "black",
use_xauth: bool = False,
# check_startup=False,
retries: int = 10,
extra_args: List[str] = [],
manage_global_env: bool = True,
**kwargs
):
self._color_depth = color_depth
self._size = size
self._bgcolor = bgcolor
self._visible = visible
self._backend = backend
if not self._backend:
if self._visible:
self._backend = "xephyr"
else:
self._backend = "xvfb"
cls = _class_map.get(self._backend)
if not cls:
raise ValueError("unknown backend: %s" % self._backend)
self._obj = cls(
size=size,
color_depth=color_depth,
bgcolor=bgcolor,
retries=retries,
use_xauth=use_xauth,
# check_startup=check_startup,
extra_args=extra_args,
manage_global_env=manage_global_env,
**kwargs
)
I do not know what to do, any help would be much appreciated. Thank You!