无法使用Chrome和Firefox在Linux Mint上运行Selenium Python脚本
内容导读
互联网集市收集整理的这篇技术教程文章主要介绍了无法使用Chrome和Firefox在Linux Mint上运行Selenium Python脚本,小编现在分享给大家,供广大互联网技能从业者学习和参考。文章包含2621字,纯文字阅读大概需要4分钟。
内容图文
我无法在Chrome和Firefox上使用Linux Mint 18.1 Serena上运行/执行python(3.5)selenium(3.4.0)脚本.
细节:
当我尝试在Chrome或Firefox浏览器的脚本下运行时,我遇到了问题,它在Windows计算机上运行正常,但在Linux Mint上却出现了一些奇怪的问题.
铬:-
import time
from selenium import webdriver
driver = webdriver.Chrome()
driver.get('http://www.google.com/xhtml');
driver.close()
结果:-
Traceback (most recent call last):
File "sample1.py", line 6, in <module>
driver.get('http://www.google.com/xhtml');
File "/usr/local/lib/python3.5/dist-packages/selenium-3.4.0-py3.5.egg /selenium/webdriver/remote/webdriver.py", line 261, in get
self.execute(Command.GET, {'url': url})
File "/usr/local/lib/python3.5/dist-packages/selenium-3.4.0-py3.5.egg/selenium/webdriver/remote/webdriver.py", line 247, in execute
response = self.command_executor.execute(driver_command, params)
File "/usr/local/lib/python3.5/dist-packages/selenium-3.4.0-py3.5.egg/selenium/webdriver/remote/remote_connection.py", line 464, in execute
return self._request(command_info[0], url, body=data)
File "/usr/local/lib/python3.5/dist-packages/selenium-3.4.0-py3.5.egg/selenium/webdriver/remote/remote_connection.py", line 488, in _request
resp = self._conn.getresponse()
File "/usr/lib/python3.5/http/client.py", line 1197, in getresponse
response.begin()
File "/usr/lib/python3.5/http/client.py", line 297, in begin
version, status, reason = self._read_status()
File "/usr/lib/python3.5/http/client.py", line 266, in _read_status
raise RemoteDisconnected("Remote end closed connection without"
http.client.RemoteDisconnected: Remote end closed connection without response
火狐:-
import time
from selenium import webdriver
driver = webdriver.Firefox()
driver.get('http://www.google.com/xhtml');
driver.close()
结果:-
Traceback (most recent call last):
File "sample1.py", line 4, in <module>
driver = webdriver.Firefox()
File "/usr/local/lib/python3.5/dist-packages/selenium-3.4.0-py3.5.egg/selenium/webdriver/firefox/webdriver.py", line 142, in __init__
self.service.start()
File "/usr/local/lib/python3.5/dist-packages/selenium-3.4.0-py3.5.egg/selenium/webdriver/common/service.py", line 74, in start
stdout=self.log_file, stderr=self.log_file)
File "/usr/lib/python3.5/subprocess.py", line 947, in __init__
restore_signals, start_new_session)
File "/usr/lib/python3.5/subprocess.py", line 1551, in _execute_child
raise child_exception_type(errno_num, err_msg)
OSError: [Errno 8] Exec format error
解决方法:
我通过更改geckodriver的权限并在/usr/local/bin下移动geckodriver解决了问题
chmod +x geckodriver
cp geckodriver /usr/local/bin/
我认为它对于chromedriver同样适用
谢谢大家的帮助
内容总结
以上是互联网集市为您收集整理的无法使用Chrome和Firefox在Linux Mint上运行Selenium Python脚本全部内容,希望文章能够帮你解决无法使用Chrome和Firefox在Linux Mint上运行Selenium Python脚本所遇到的程序开发问题。 如果觉得互联网集市技术教程内容还不错,欢迎将互联网集市网站推荐给程序员好友。
内容备注
版权声明:本文内容由互联网用户自发贡献,该文观点与技术仅代表作者本人。本站仅提供信息存储空间服务,不拥有所有权,不承担相关法律责任。如发现本站有涉嫌侵权/违法违规的内容, 请发送邮件至 gblab@vip.qq.com 举报,一经查实,本站将立刻删除。
内容手机端
扫描二维码推送至手机访问。