
driver = webdriver.Firefox(firefox_profile=ffprofile) File "/usr/local/lib/python2.7/dist-packages/selenium/webdriver/firefox/webdriver.py", line 65, in __init__ self.service.start() File "/usr/local/lib/python2.7/dist-packages/selenium/webdriver/common/service.py", line 71, in start os.path.basename(self.path), self.start_error_message) selenium.common.exceptions.WebDriverException: Message: 'geckodriver' executable needs to be in PATH. Exception AttributeError: "'Service' object has no attribute 'process'" in <bound method Service.__del__ of <selenium.webdriver.firefox.service.Service object at 0x3359310>> ignored 报错信息如上..
报错原因; MAC OS 执行没有问题, 换了环境去了 Ubuntu 出错了. 努力 GOOGLE 没找到办法, 谢谢大家了.
1 ykrl089 2016 年 8 月 2 日 查下文件或者路径的大小写问题 |
2 redhatping OP @ykrl089 没明白. |
3 xchange 2016 年 8 月 2 日 提示里面不是说了'geckodriver' executable needs to be in PATH 吗? |
4 redhatping OP @xchange firefox 在 usr/bin 下面啊... 么有问题啊 echo $PATH /usr/bin: 也有啊.. |
5 Garantion 2016 年 8 月 2 日 你确定是 ubuntu server ?我记得我当时用 Selenium 的时候没有图形界面是无法运行的。 |
6 redhatping OP @Garantion 我安装了图形界面啊.. xfce |
7 ykrl089 2016 年 8 月 2 日 @redhatping mac 系统文件名和路径不区分大小写, linux 一般是区分大小写的, 也就是说在 linux 下 geckodriver != Geckodriver 你自己看下文件名和路径名有没有错误 |
8 redhatping OP @ykrl089 这么说 , 我运行以下代码就有问题了 ``python from selenium import webdriver driver = webdriver.Firefox() ``` 就会报错了... 这个不可能是大小写出现的吧. |
9 ykrl089 2016 年 8 月 2 日 |
10 eclipselu 2016 年 8 月 2 日 看起来是 geckodriver 没在 PATH 里,实在不行换个别的浏览器试试看?比如 ChromeDriver ,或者 PhantomJS |
11 redhatping OP @eclipselu 对啊, 但是 firefox 不是默认的嘛.. geckodriiver 也在 /usr/bin/firefox (firefox) |
12 redhatping OP @ykrl089 #65 self.service.start() #71 os.path.basename(self.path), self.start_error_message 这两个判断, 都是系统路径的问题. 但是我 firefox 确实已经安装了 . 就在 usr/bin 里面 |
13 mrwangrj 2016 年 8 月 2 日 好巧今早遇到了长得差不多的问题,我这边是用的 PhantomJS ,换了个环境发现没有在 PATH 里 |
14 redhatping OP @mrwangrj 你是怎么解决的. 我$PATH 也在 USR/BIN 里面啊.. |
15 mrwangrj 2016 年 8 月 2 日 @redhatping 是不是需要 /usr/bin/firefox 搞到$PATH 里? |
16 eclipselu 2016 年 8 月 2 日 @redhatping 不太清楚 Ubuntu 下面是怎么样,好像我当时用的时候是单独装了一个 geckodriver https://github.com/mozilla/geckodriver 。就是 Firefox 和 geckodriver 都要有。 |
17 gimp 2016 年 8 月 2 日 看你的 Firefox 版本,如果太高了会报错, selenium 对新版火狐支持不好 你也可以安装个 chrome ,然后下载个 chrome driver 来用( http://chromedriver.storage.googleapis.com/index.html?path=2.22/) |
18 redhatping OP @gimp MAC 我也是新版本, 似乎没撒问题. 就是叫降低版本看看? |
19 redhatping OP @eclipselu 我试试 |
20 IMRES 2016 年 8 月 2 日 检查`which geckodriver`得到的目录是否在"$PATH"中 |
21 Garantion 2016 年 8 月 2 日 @redhatping 我之前也是在 MAC 下开发的,不过移动到的就是普通的 ubuntu 14.04 LTS , server 装了界面这个就不清楚了。 |
22 sodatea 2016 年 8 月 2 日 via iPhone geckodriver 跟 firefox 又不是一回事…… |
23 redhatping OP @IMRES 没这个东西 whick 是空的 |
24 redhatping OP @eclipselu 没看懂怎么安装 geckodriver |
25 redhatping OP @sodatea 对啊, 似乎是两个东西 请问怎么办呢 |
26 eclipselu 2016 年 8 月 2 日 @redhatping https://github.com/mozilla/geckodriver/releases 这里下载一个 linux64 下的放到 PATH 下的随便一个目录试试看? |
27 eclipselu 2016 年 8 月 2 日 @redhatping 或者自己编译一个 |
28 redhatping OP @eclipselu 好好 试试 |
29 redhatping OP @eclipselu 解决了 就是这个问题 mark: answer: download geckodriver to /usr/bin . the urllink of geckodriver is github.com/mozilla/geckodriver releases. ubuntu server . |