Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

KeyError: 'DISPLAY' in stop #27

Open
ryancc9 opened this issue Apr 3, 2017 · 1 comment
Open

KeyError: 'DISPLAY' in stop #27

ryancc9 opened this issue Apr 3, 2017 · 1 comment

Comments

@ryancc9
Copy link

ryancc9 commented Apr 3, 2017

Hi,
Thanks for the awesome wrapper!
I'm getting the below error running dryscrape with xvfbwrapper.
Ubuntu 16.04.2 LTS (Ubuntu Mate)
Python 2.7.12
xvfbwrapper-0.2.9

Error in sys.exitfunc:
Traceback (most recent call last):
File "/usr/lib/python2.7/atexit.py", line 24, in _run_exitfuncs
func(*targs, **kargs)
File "/usr/local/lib/python2.7/dist-packages/xvfbwrapper.py", line 84, in stop
del os.environ['DISPLAY']
File "/usr/lib/python2.7/os.py", line 498, in delitem
del self.data[key]
KeyError: 'DISPLAY'

I'm not sure this is the best solution, but I was able to fix this by adding "if 'DISPLAY' in os.environ:" to check that 'DISPLAY' actually exists.

            if self.orig_display is None:
                if 'DISPLAY' in os.environ:
                   del os.environ['DISPLAY']

@gariel
Copy link

gariel commented Jul 10, 2019

I have the same problem, to temporary fix I added the DISPLAY key on os.environ dict before start:

    def start(self):
        # fixing an exception raised in xvfb
        os.environ['DISPLAY'] = ':0'

        self._xvfb.start()

Python 3.7.3
xvfbwrapper-0.2.9

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants