[英]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: 请再次确认您已完成以下步骤:
pip install -U selenium
command pip install -U selenium
命令下载硒 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版本) 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\\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.