Use*_*ser 17 python ubuntu selenium
在Ubuntu中安装Selenium并在路径中添加geckodriver后,运行时出现此错误
from selenium import webdriver
driver = webdriver.Firefox()
Run Code Online (Sandbox Code Playgroud)
错误:
Traceback (most recent call last):
File "<stdin>", line 1, in <module>
File "/usr/local/lib/python2.7/dist-packages/selenium/webdriver/firefox/webdriver.py", line 135, in __init__
self.service.start()
File "/usr/local/lib/python2.7/dist-packages/selenium/webdriver/common/service.py", line 64, in start
stdout=self.log_file, stderr=self.log_file)
File "/usr/lib/python2.7/subprocess.py", line 710, in __init__
errread, errwrite)
File "/usr/lib/python2.7/subprocess.py", line 1327, in _execute_child
raise child_exception
OSError: [Errno 20] Not a directory
Run Code Online (Sandbox Code Playgroud)
这是怎么回事?
编辑:解决使用chromedriver而不是geckodriver.
小智 34
有同样的问题.有两种方法可以解决这个问题:
在webdriver中添加executable_path arg:
driver = webdriver.Firefox(executable_path='/path/to/geckodriver')
Run Code Online (Sandbox Code Playgroud)
第二种方式是使用export添加包含geckodriver的文件夹(仅限文件夹,而不是geckodriver):
$ export PATH=$PATH:/path/to/
Run Code Online (Sandbox Code Playgroud)
| 归档时间: |
|
| 查看次数: |
19536 次 |
| 最近记录: |