Macos WebDriverException:';壁虎河';可执行文件需要在路径中,即使它是
试图让firefox在spyder中使用selenium运行。我现在的代码是Macos WebDriverException:';壁虎河';可执行文件需要在路径中,即使它是,macos,selenium,firefox,selenium-webdriver,geckodriver,Macos,Selenium,Firefox,Selenium Webdriver,Geckodriver,试图让firefox在spyder中使用selenium运行。我现在的代码是 from selenium import webdriver import os os.environ["PATH"] += ":/usr/local/bin/geckodriver" browser = webdriver.Firefox() 我仍然得到这个错误: runfile('/Users/mherl/Dropbox/AnacondaProjects/MWS/MWSSpyder/test.py', wdir
from selenium import webdriver
import os
os.environ["PATH"] += ":/usr/local/bin/geckodriver"
browser = webdriver.Firefox()
我仍然得到这个错误:
runfile('/Users/mherl/Dropbox/AnacondaProjects/MWS/MWSSpyder/test.py',
wdir='/Users/mherl/Dropbox/AnacondaProjects/MWS/MWSSpyder')
Traceback (most recent call last):
File "<ipython-input-1-3f3f96ccf515>", line 1, in <module>
runfile('/Users/mherl/Dropbox/AnacondaProjects/MWS/MWSSpyder/test.py',
wdir='/Users/mherl/Dropbox/AnacondaProjects/MWS/MWSSpyder')
File "/Applications/anaconda3/lib/python3.6/site-
packages/spyder/utils/site/sitecustomize.py", line 705, in runfile
execfile(filename, namespace)
File "/Applications/anaconda3/lib/python3.6/site-
packages/spyder/utils/site/sitecustomize.py", line 102, in execfile
exec(compile(f.read(), filename, 'exec'), namespace)
File "/Users/mherl/Dropbox/AnacondaProjects/MWS/MWSSpyder/test.py",
line 12, in <module>
browser = webdriver.Firefox()
File "/Applications/anaconda3/lib/python3.6/site-
packages/selenium/webdriver/firefox/webdriver.py", line 152, in
__init__
self.service.start()
File "/Applications/anaconda3/lib/python3.6/site-
packages/selenium/webdriver/common/service.py", line 83, in start
os.path.basename(self.path), self.start_error_message)
WebDriverException: 'geckodriver' executable needs to be in PATH.
我还在spyder中设置了当前路径:
/usr/local/bin
/Users/mherl/Dropbox/AnacondaProjects/MWS/MWSSpyder
gekodriver在其中
/usr/local/bin
我到处都找过了,大多数人说如果它在/usr/local/bin中,它应该自动运行,但即使我显式地声明了路径,它似乎仍然找不到它
这是一台运行速度很高的mac电脑,如果这很重要的话。此错误消息
WebDriverException: 'geckodriver' executable needs to be in PATH.
…表示在预期的默认位置未找到GeckoDriver
解决方案
当您使用基于MAC的系统时,需要传递键可执行路径以及引用GeckoDriver绝对路径的值,如下所示:
from selenium import webdriver
browser = webdriver.Firefox(executable_path='/usr/local/bin/geckodriver')
额外考虑
确保:
- GeckoDriver位于指定位置
- GeckoDriver对非root用户具有可执行权限
- 以非root用户身份执行@Test
WebDriverException: 'geckodriver' executable needs to be in PATH.
…表示在预期的默认位置未找到GeckoDriver
解决方案
当您使用基于MAC的系统时,需要传递键可执行路径以及引用GeckoDriver绝对路径的值,如下所示:
from selenium import webdriver
browser = webdriver.Firefox(executable_path='/usr/local/bin/geckodriver')
额外考虑
确保:
- GeckoDriver位于指定位置
- GeckoDriver对非root用户具有可执行权限
- 以非root用户身份执行@Test