小编use*_*469的帖子

在PyDev中使用virtualenv运行Selenium Chrome时,如何解决"chromedriver可执行文件需要处于PATH"错误?

短:

https://automatetheboringstuff.com/chapter11上阅读了使用selenium模块控制浏览器后,我试图在PyDev的虚拟环境中运行Selenium Chrome驱动程序.我已经设法从PyDev外部做到了,但是从内部,我得到:

selenium.common.exceptions.WebDriverException: Message: 'chromedriver' executable needs to be in PATH.

长:

我正在使用Linux Debian 3.10.11-1.

关注https://www.dabapps.com/blog/introduction-to-pip-and-virtualenv-python/,在开始使用PyDev之前,我...

  1. 使用virtualenv设置虚拟环境

    1. 安装virtualenv

      pip install virtualenv
    2. 为我的项目制作了一个目录

      cd ~/temp/
      mkdir my_project
      cd my_mproject
    3. 创建了一个名为的虚拟环境 env

      virtualenv env
    4. 激活了它.

      source env/bin/activate
    5. 进入Python的交互模式,告诉自己我使用的是哪个版本的Python

      python
      Python 2.7.12rc1 (default, Jun 13 2016, 09:20:59) 
      [GCC 5.4.0 20160609] on linux2
  2. 退出交互模式并安装了Selenium的东西

    1. 首先是模块

      pip install selenium
    2. 根据https://groups.google.com/forum/#!topic/obey-the-testing-goat-book/Ty4FQoV3S0Q的建议,安装了chromedriver

      1. cd env/bin/
      2. wget http://chromedriver.storage.googleapis.com/2.22/chromedriver_linux64.zip
      3. unzip chromedriver_linux64.zip
  3. 写了一个小脚本,看看它是否有效

    from selenium import webdriver
    driver = webdriver.Chrome()

    跑吧.Chrome网络浏览器窗口已打开.大.

现在在PyDev中尝试: …

python selenium pydev virtualenv selenium-chromedriver

10
推荐指数
1
解决办法
1万
查看次数