如何在Linux中将Chromedriver添加到PATH?

编程入门 行业动态 更新时间:2024-10-26 09:30:26
本文介绍了如何在Linux中将Chromedriver添加到PATH?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧! 问题描述

尝试在Python脚本中将Selenium与Chrome结合使用.

Trying to use Selenium with Chrome in a python script.

我收到以下错误:

WebDriverException: Message: 'chromedriver' executable needs to be in PATH. Please see sites.google/a/chromium/chromedriver/home

我知道chromedriver可执行文件的位置. 如何将其添加到PATH?

I know the location of the chromedriver executable. How do I add it to the PATH?

谢谢

推荐答案

您可以在脚本中指定chrome驱动程序的绝对路径,如下所示:

You can specify the absolute path to your chrome driver in your script as such:

from selenium import webdriver driver = webdriver.Chrome(executable_path='/path/to/driver/chromedriver')

或者您可以在PATH系统变量中将网络驱动器的路径添加为:

Or you can add the path to your webdriver in the PATH system variable as so:

export PATH=$PATH:/path/to/driver/chrome-driver

您可以将以上行添加到您的/home/<user>/.profile文件中,以使其永久保存.

You may add the above line to your /home/<user>/.profile file to make it permanent.

在运行Python 2.7.14的Ubuntu 17.10上测试

Tested on Ubuntu 17.10 running Python 2.7.14

希望这会有所帮助!

更多推荐

如何在Linux中将Chromedriver添加到PATH?

本文发布于:2023-05-31 10:08:09,感谢您对本站的认可!
本文链接:https://www.elefans.com/category/jswz/34/389591.html
版权声明:本站内容均来自互联网,仅供演示用,请勿用于商业和其他非法用途。如果侵犯了您的权益请与我们联系,我们将在24小时内删除。
本文标签:中将   如何在   PATH   Linux   Chromedriver

发布评论

评论列表 (有 0 条评论)
草根站长

>www.elefans.com

编程频道|电子爱好者 - 技术资讯及电子产品介绍!