简体   繁体   English

pyvirtualdisplay在Amazon EC2实例上

[英]pyvirtualdisplay on Amazon EC2 instance

I am trying to run selenium on Amazon EC2. 我正在尝试在Amazon EC2上运行硒。 I am using pyvirtualdisplay as xvfb wrapper. 我正在使用pyvirtualdisplay作为xvfb包装器。 I ran the following commands in python. 我在python中运行了以下命令。

from pyvirtualdisplay import Display
from selenium import webdriver
display = Display(visible=0, size=(1024, 768))
display.start()

Everything goes fine till now. 到目前为止一切都很好。
But when I do: 但是当我这样做时:

driver = webdriver.Firefox()

I get this error: 我收到此错误:

Traceback (most recent call last):
File "<stdin>", line 1, in <module>
File "/usr/lib/python2.6/site-   packages/selenium/webdriver/firefox/webdriver.py", line 59, in __init__
self.binary, timeout),
File "/usr/lib/python2.6/site-packages/selenium/webdriver/firefox/extension_connection.py", line 47, in  __init__
self.binary.launch_browser(self.profile)
File "/usr/lib/python2.6/site-packages/selenium/webdriver/firefox/firefox_binary.py", line 66, in launch_browser
self._wait_until_connectable()
File "/usr/lib/python2.6/site- packages/selenium/webdriver/firefox/firefox_binary.py", line 100, in _wait_until_connectable
raise WebDriverException("The browser appears to have exited "
selenium.common.exceptions.WebDriverException: Message: The browser   appears to have exited before we could connect. If you specified a    log_file in the FirefoxBinary constructor, check it for details.

After spending many hours on the internet searching for solutions and trying every possible thing out, one thing which worked for me is this. 在互联网上花费了许多时间寻找解决方案并尝试了所有可能的方法之后,对我有用的一件事就是这个。
https://superuser.com/questions/870702/aws-ec2-linux-headless-firefox-issue-xvfb-undefined-symbol-pixman-glyph-cache https://superuser.com/questions/870702/aws-ec2-linux-headless-firefox-issue-xvfb-undefined-symbol-pixman-glyph-cache

As the answer says: 正如答案所说:
It is trying to load wring pixman so. 它正试图加载扭曲的pixman。 Delete /usr/local/lib/libpixman-1.so.0 and try again, it will make Xvfb use distribution pixman library which has this symbol. 删除/usr/local/lib/libpixman-1.so.0并再试一次,它将使Xvfb使用带有此符号的发行pixman库。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM