jonggu jonggu - 4 months ago 31
Python Question

Python OSError: [Errno 2] No such file err

I'm trying to use python webdriver to get html source in linux.

But I got below error:

python ''Traceback (most recent call last):
File "/var/www/daiwa/lib/otas/", line 9, in <module>
xephyr=Display(visible=1, size=(320, 240)).start()
File "/usr/local/lib/python2.7/site-packages/pyvirtualdisplay/", line 33, in __init__self._obj = self.display_class(
File "/usr/local/lib/python2.7/site-packages/pyvirtualdisplay/", line 51, in display_classcls.check_installed()
File "/usr/local/lib/python2.7/site-packages/pyvirtualdisplay/", line 30, in check_installed ubuntu_package=PACKAGE).check_installed()
File "/usr/local/lib/python2.7/site-packages/easyprocess/", line 180, in check_installed
raise EasyProcessCheckInstalledError(self)
easyprocess.EasyProcessCheckInstalledError: cmd=['Xephyr', '-help']
OSError=[Errno 2] No such file or directory
Program install error!

Can someone help me?

version: python -> 2.7.9
This is my code.

#-*- coding: utf-8 -*-
from pyvirtualdisplay import Display
from selenium import webdriver

xephyr=Display(visible=1, size=(320, 240)).start()

path_to_chromedriver = "/usr/local/bin/chromedriver"

templete = webdriver.Chrome("/usr/local/bin/chromedriver")


html_source = templete.page_source

if isinstance(html_source, unicode):
html_source = html_source.encode('UTF-8')

print html_source



In your code Change line

xephyr=Display(visible=1, size=(320, 240)).start()


xephyr=Display(visible=0, size=(320, 240)).start()  # visible=0

If backend Xephyr::

display = Display(visible=1, size=(320, 240)).start()  # visible=1

if backend Xvfb:

display = Display(visible=0, size=(320, 240)).start()  # visible=0