本文介绍了Python-Ubuntu OS中的Selenium错误:[Errno 20]不是目录的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
在Ubuntu中安装Selenium并将geckodriver添加到路径后,运行时会出现此错误
After installing Selenium in Ubuntu and adding geckodriver to path I get this error when I run
from selenium import webdriver
driver = webdriver.Firefox()
错误:
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
这是怎么回事?
使用chromedriver代替geckodriver解决了.
Solved using chromedriver instead of geckodriver.
推荐答案
出现相同的问题.有两种方法可以为我解决此问题:
Had the same problem. There were two ways to fix this for me:
在网络驱动程序中添加execute_path arg:
Add executable_path arg in webdriver:
driver = webdriver.Firefox(executable_path='/path/to/geckodriver')
第二种方法是使用export添加包含geckodriver的文件夹(仅文件夹,而不是geckodriver):
And the second way its to add folder that contains geckodriver using export (only folder, not geckodriver):
$ export PATH=$PATH:/path/to/
这篇关于Python-Ubuntu OS中的Selenium错误:[Errno 20]不是目录的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!