首页
学习
活动
专区
圈层
工具
发布
首页
学习
活动
专区
圈层
工具
MCP广场
社区首页 >问答首页 >Python在我的路径中找不到geckodriver

Python在我的路径中找不到geckodriver
EN

Stack Overflow用户
提问于 2018-07-18 03:34:04
回答 2查看 4.2K关注 0票数 1

我是Python的新手,现在,我正在通过Al Sweigart的Automate the boring with python学习python。

现在,我想用webdriver打开一个Firefox。当我运行代码时:

代码语言:javascript
运行
复制
from selenium import webdriver

我没有得到任何错误。但是,在运行以下命令后:

代码语言:javascript
运行
复制
browswer=webdriver.Firefox()

我得到以下错误消息。

代码语言:javascript
运行
复制
Traceback (most recent call last):
File "/Library/Frameworks/Python.framework/Versions/3.6/lib/python3.6/site-packages/selenium/webdriver/common/service.py", line 76, in start
stdin=PIPE)
File "/Library/Frameworks/Python.framework/Versions/3.6/lib/python3.6/subprocess.py", line 709, in __init__
restore_signals, start_new_session)
File "/Library/Frameworks/Python.framework/Versions/3.6/lib/python3.6/subprocess.py", line 1344, in _execute_child
raise child_exception_type(errno_num, err_msg, err_filename)
FileNotFoundError: [Errno 2] No such file or directory: 'geckodriver': 'geckodriver'

During handling of the above exception, another exception occurred:

Traceback (most recent call last):
File "<pyshell#2>", line 1, in <module>
browswer=webdriver.Firefox()
File "/Library/Frameworks/Python.framework/Versions/3.6/lib/python3.6/site-packages/selenium/webdriver/firefox/webdriver.py", line 160, in __init__
self.service.start()
File "/Library/Frameworks/Python.framework/Versions/3.6/lib/python3.6/site-packages/selenium/webdriver/common/service.py", line 83, in start
os.path.basename(self.path), self.start_error_message)
selenium.common.exceptions.WebDriverException: Message: 'geckodriver' executable needs to be in PATH. 

现在,我已经安装了geckodriver,我一直在谷歌上滚动,试图找到解决方案。到目前为止,我已经尝试手动将geckodriver添加到/usr/local/bin。我也尝试过跑步:

代码语言:javascript
运行
复制
brew install geckodriver 

在终端上。它建议我尝试重写geckodriver,因此brew在/usr/local/Cellar/geckodriver/0.21.0/bin/geckodriver.上安装了geckodriver

我跑过了

代码语言:javascript
运行
复制
sudo nano /etc/paths 

来查看我的路径列表,下面是列表:

代码语言:javascript
运行
复制
/usr/local/bin
/usr/bin
/bin
/usr/sbin
/sbin
/usr/local/Cellar/geckodriver/0.21.0/bin/geckodriver

所以我不知道为什么python告诉我geckodriver可执行文件需要在PATH中,而它已经存在了。

有谁能帮帮我吗?

EN
页面原文内容由Stack Overflow提供。腾讯云小微IT领域专用引擎提供翻译支持
原文链接:

https://stackoverflow.com/questions/51388985

复制
相关文章

相似问题

领券
问题归档专栏文章快讯文章归档关键词归档开发者手册归档开发者手册 Section 归档