简体   繁体   English

AttributeError: 模块“selenium.webdriver”没有属性“webdriver”

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

I've installed selenium correctly as well as the chromium webdriver for selenium and I keep getting the following error我已经正确安装了硒以及硒的铬网络驱动程序,但我不断收到以下错误

    Traceback (most recent call last):
  File "C:/Users/Turtle/PycharmProjects/SpotifyWebscraper/seleniumTest.py", line 3, in <module>
    driver = webdriver.chrome()
TypeError: 'module' object is not callable

here is my code:这是我的代码:

from selenium import webdriver

driver = webdriver.chrome()
driver.get("htts://www.google.com")

print(driver.title)
print(driver.current_url)

driver.quit

I've checked in the folders correctly and the files seem to be in the right positions:我已正确签入文件夹,文件似乎位于正确的位置:

C:\Users\Turtle\AppData\Local\Programs\Python\Python38\Lib\site-packages\selenium-4.0.0a3-py3.8.egg\selenium\webdriver\chromium

contains webdriver.py包含 webdriver.py

If you look at the way Selenium imports the various flavours of webdriver to selenium.webdriver you can see that the import you want is Chrome如果您查看 Selenium 将各种风格的webdriver导入selenium.webdriver您可以看到您想要的导入是Chrome

from .firefox.webdriver import WebDriver as Firefox  # noqa
from .chrome.webdriver import WebDriver as Chrome  # noqa

So you would do driver = webdriver.Chrome() or if you want Firefox, webdriver.Firefox()所以你会做driver = webdriver.Chrome()或者如果你想要 Firefox, webdriver.Firefox()

By doing webdriver.chrome() you're importing & calling the actual chrome module通过执行webdriver.chrome()您正在导入和调用实际的chrome 模块

In terms of your new error, you need to download the chromedriver executable and make sure it's in a folder which is available to python (included in your PATH ).就您的新错误而言,您需要下载 chromedriver 可执行文件并确保它位于 python 可用的文件夹中(包含在您的PATH )。 You can download chromedriver here;你可以在这里下载 chromedriver; https://sites.google.com/a/chromium.org/chromedriver/downloads https://sites.google.com/a/chromium.org/chromedriver/downloads

The error in your title is different than the one in your post.您标题中的错误与您帖子中的错误不同。

TypeError: 'module' object is not callable

chrome should be capitalized in webdriver.chrome() : chrome应该在webdriver.chrome()大写:

driver = webdriver.Chrome() # .Chrome(), not .chrome()

暂无
暂无

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

相关问题 AttributeError:模块“selenium.webdriver”没有属性“find_element” - AttributeError: module 'selenium.webdriver' has no attribute 'find_element' AttributeError:模块&#39;selenium.webdriver&#39;没有属性&#39;Chrome&#39; - AttributeError: module 'selenium.webdriver' has no attribute 'Chrome' AttributeError 问题:模块“selenium.webdriver”没有属性“Chrome” - AttributeError Issue: module 'selenium.webdriver' has no attribute 'Chrome' 模块“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: 模块“selenium.webdriver”没有属性“Chrome”错误,使用 ChromeDriver 和 Chrome 通过 Selenium - AttributeError: module 'selenium.webdriver' has no attribute 'Chrome' error using ChromeDriver and Chrome through Selenium 没有名为“selenium.webdriver”的模块 - No module named 'selenium.webdriver' Selenium错误消息“ selenium.webdriver没有属性执行脚本” - Selenium error message “selenium.webdriver has no attribute execute script” AttributeError:模块'selenium.webdriver.common.keys'没有属性'RETURN' - AttributeError: module 'selenium.webdriver.common.keys' has no attribute 'RETURN'
 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM