gpt4 book ai didi

python - Selenium firefox 浏览器无法在使用 Python 的 centos 6.0 上运行

转载 作者:行者123 更新时间:2023-12-02 15:58:33 25 4
gpt4 key购买 nike

如何让 Selenium 在 Centos 6.0 上工作?我收到以下错误。我在 python 2.6 上使用 selenium 2.31.0

yum install ImageMagick ImageMagick-perl  xorg-x11-server-Xephyr Xvfb firefox
sudo yum -y install python-imaging
sudo easy_install pyvirtualdisplay
sudo easy_install selenium

from pyvirtualdisplay import Display
from selenium import webdriver
import time
import argparse
import os
display = Display(visible=0, size=(800, 600))
display.start()
browser = webdriver.Firefox()


Traceback (most recent call last):
File "<stdin>", line 1, in <module>
File "/usr/lib/python2.6/site-packages/selenium-2.31.0-py2.6.egg/selenium/webdriver/firefox/webdriver.py", line 58, in __init__
self.binary, timeout),
File "/usr/lib/python2.6/site-packages/selenium-2.31.0-py2.6.egg/selenium/webdriver/firefox/extension_connection.py", line 47, in __init__
self.binary.launch_browser(self.profile)
File "/usr/lib/python2.6/site-packages/selenium-2.31.0-py2.6.egg/selenium/webdriver/firefox/firefox_binary.py", line 48, in launch_browser
self._wait_until_connectable()
File "/usr/lib/python2.6/site-packages/selenium-2.31.0-py2.6.egg/selenium/webdriver/firefox/firefox_binary.py", line 95, in _wait_until_connectable
self.profile.path, self._get_firefox_output()))
selenium.common.exceptions.WebDriverException: Message: 'Can\'t load the profile. Profile Dir: /tmp/tmpUYQhu2 Firefox output: Xlib: extension "RANDR" missing on display ":1170.0".
*** LOG addons.xpi: startup
*** LOG addons.xpi: Ignoring file entry whose name is not a valid add-on ID: /home/efuadmin/.mozilla/extensions/{ec8030f7-c20a-464f-9b0e-13a3a9e97384}/.fedora-langpack-install
*** LOG addons.xpi: checkForChanges
*** LOG addons.xpi: No changes found'

最佳答案

对于 python 2.7,selenium 需要安装 pip:

/usr/bin/python2.7 -m pip install --user selenium

在你的 python 2.6 上试试这个。它适用于 Red Hat 6 和 Centos 6。

为了避免调用可执行文件时出现路径问题,您也可以使用此选项:

driver = webdriver.Firefox(executable_path='/bin/geckodriver')

关于python - Selenium firefox 浏览器无法在使用 Python 的 centos 6.0 上运行,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/15339398/

25 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com