【问题标题】:Error while installing selenium webdriver on ubuntu, using python3, chrome在ubuntu上安装selenium webdriver时出错,使用python3,chrome
【发布时间】:2017-04-10 18:52:55
【问题描述】:

我正处于使用 Python3 在 Ubuntu 上安装 Selenium 的阶段(我想自动化 Chrome)。

我已经安装了 pip3、chromedriver,当我在 Pycharm 中运行以下代码时:

import os  
from selenium import webdriver  
chromedriver = '/home/anastasia/development/python/projects/selenium/chromedriver'  
os.environ['webdriver.chrome.driver'] = chromedriver  
driver = webdriver.Chrome(chromedriver)  
driver.get("http://stackoverflow.com")  

收到错误“ImportError: cannot import name 'webdriver'”然后我在 webdriver 上按 alt+Enter - 选择安装包并收到错误:

"安装包失败。pip install webdriver非零退出码 (1)"

我认为问题出在使用的 pip 版本上。如何正确设置要使用的 pip3 版本?

【问题讨论】:

  • “pip --version”的结果是什么?
  • 尝试使用 pip3 install webdriver 安装
  • @JeroenHeier :~$ pip --version pip 9.0.1 from /home/anastasia/.local/lib/python2.7/site-packages (python 2.7) :~$ pip3 --version来自 /home/anastasia/.local/lib/python3.5/site-packages 的 pip 9.0.1 (python 3.5)
  • @zhiqianghuang 试过“pip3 install webdriver”它说:Collecting webdriver Could not find a version that satisfies the requirements webdriver (from versions: ) No matching distribution found for webdriver
  • pip3 install selenium 要求已经满足:/usr/local/lib/python3.5/dist-packages 中的 selenium

标签: python selenium ubuntu selenium-webdriver


【解决方案1】:

问题出在 google-chrome 版本中。看来我不是最新的。而且它与最新的 chromedriver 不兼容。在我升级 chrome 后,一切都成功了!

【讨论】:

    猜你喜欢
    • 2016-09-06
    • 2017-01-03
    • 1970-01-01
    • 2019-07-23
    • 2019-10-27
    • 2020-03-14
    • 2019-08-08
    • 2017-10-20
    • 1970-01-01
    相关资源
    最近更新 更多