I am trying to run a python code on a Linux server, and my code involves running Selenium.
soon after I started running the code, the following error popped up:
The browser appears to have exited before we could connect. The output was: Error: cannot open display:
I installed firefox and selenium, but for some reason the error is keep popping up
how can I solve this issue?
thank you
I'm guessing you need a $DISPLAY variable, and xauth or xhost.
Selenium depends on a browser, and your browser on Linux depends on X11.  $DISPLAY tells X11 where to find the X server (the thing that renders the graphics - usually this is on the computer you're sitting in front of), and xauth or xhost tells the remote host how to authenticate to the X server.
If you're using putty to connect to the Linux host (or other X11-less ssh client), you'll probably need to install an X server on the machine you're sitting in front of, and then use Cygwin ssh -Y to forward xauth creds to the remote host.
Another option that works pretty well for many people is to use VNC.  This allows you to reboot the machine you're sitting in front of, without interrupting your Selenium tests.  There are many interoperable VNC client/servers.
You can easily test your X11 communication by just running "xterm &" or "xdpyinfo".  If this displays a command window on the machine you're sitting in front of, X11's set up.
running a python code that includes selenium module gives an error