简体   繁体   English

AttributeError:模块'selenium.webdriver'没有属性'Chrome'

[英]AttributeError: module 'selenium.webdriver' has no attribute 'Chrome'

I tried below code: 我尝试下面的代码:

from selenium import webdriver
driver=webdriver.Chrome("C:\\Python\\Python36\\Lib\\site-packages\\selenium\\webdriver\\chrome.chromedriver.exe")
driver.get('https://www.google.com')

Error I got: 我得到的错误:

C:\Users\utkarsh\PycharmProjects\SeleniumScripts\venv\Scripts\python.exe "C:/Users/utkarsh/PycharmProjects/SeleniumScripts/selenium examples/prog1.py"
Traceback (most recent call last):
  File "C:/Users/utkarsh/PycharmProjects/SeleniumScripts/selenium examples/prog1.py", line 3, in <module>
    driver=webdriver.Chrome("C:\\Python\\Python36\\Lib\\site-packages\\selenium\\webdriver\\chrome.chromedriver.exe")
    AttributeError: module 'selenium.webdriver' has no attribute 'Chrome'

Process finished with exit code 1

Need help to get started with selenium, please help 需要帮助来开始使用硒,请帮助

Looks like you have a script called selenium.py . 看起来您有一个名为selenium.py的脚本。 Rename that and it should work. 重命名它,它应该可以工作。

please reconfirm you have done following steps: 请再次确认您已完成以下步骤:

  1. Download selenium by using pip install -U selenium command 使用pip install -U selenium命令下载硒
  2. Download the chromedriver.exe , and put it's path into system variable (In order to confirm if you have put correct path, start command prompt and insert chromedriver , if succeed, your chrome version should be displayed) 下载chromedriver.exe ,并将其路径放入系统变量中(为了确认您是否输入了正确的路径,请启动命令提示符并插入chromedriver ,如果成功,则应显示您的chrome版本)
  3. When you installed python, in python\\Lib\\site-packages folder there is a built-in selenium package, by that saying, when you put from selenium import webdriver this will import webdriver from the built-in selenium package but not the one you just installed in step1, in order for python to import from your newly installed selenium package (because this package contains stuffs we need), you can simply replace python\\Lib\\site-packages\\selenium by your newly installed selenium folder. 当您安装python时,在python\\Lib\\site-packages文件夹中有一个内置的selenium软件包,也就是说,当您from selenium import webdriver放入时from selenium import webdriver这将从内置的selenium软件包中导入webdriver ,但不会从您导入的刚安装在步骤1中,为了使python从您新安装的selenium package导入(因为此软件包包含我们需要的东西),您只需将python\\Lib\\site-packages\\selenium替换为新安装的selenium文件夹。

暂无
暂无

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

相关问题 AttributeError 问题:模块“selenium.webdriver”没有属性“Chrome” - AttributeError Issue: module 'selenium.webdriver' has no attribute 'Chrome' AttributeError: 模块“selenium.webdriver”没有属性“Chrome”错误,使用 ChromeDriver 和 Chrome 通过 Selenium - AttributeError: module 'selenium.webdriver' has no attribute 'Chrome' error using ChromeDriver and Chrome through Selenium AttributeError: 模块“selenium.webdriver”没有属性“webdriver” - AttributeError: module 'selenium.webdriver' has no attribute 'webdriver' AttributeError:模块“selenium.webdriver”没有属性“find_element” - AttributeError: module 'selenium.webdriver' has no attribute 'find_element' 模块“selenium.webdriver”没有属性“PhantomJS” - module 'selenium.webdriver' has no attribute 'PhantomJS' 模块“selenium.webdriver”没有属性“get” - module 'selenium.webdriver' has no attribute 'get' AttributeError:模块“selenium.webdriver”在 Selenium webdriver 中没有属性“w3c” - AttributeError: module 'selenium.webdriver' has no attribute 'w3c' in Selenium webdriver AttributeError: module 'selenium.webdriver.chrome.webdriver' has no attribute 'Chrome' 错误使用 Selenium ChromeDriver 和 Chrome - AttributeError: module 'selenium.webdriver.chrome.webdriver' has no attribute 'Chrome' error using Selenium ChromeDriver and Chrome Selenium错误消息“ selenium.webdriver没有属性执行脚本” - Selenium error message “selenium.webdriver has no attribute execute script” 没有名为“selenium.webdriver”的模块 - No module named 'selenium.webdriver'
 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM