TypeError: 'module' object is not callable error with driver=webdriver("C:\Python34\Lib\site-packages\selenium\webdriver\chromedriver.exe") [英] TypeError: 'module' object is not callable error with driver=webdriver("C:\Python34\Lib\site-packages\selenium\webdriver\chromedriver.exe")

查看:31
本文介绍了TypeError: 'module' object is not callable error with driver=webdriver("C:\Python34\Lib\site-packages\selenium\webdriver\chromedriver.exe")的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我收到了类似 Pycharm 的错误:

I am getting an error like in Pycharm:

Traceback (most recent call last):   
File "C:/PycharmProjects/DemoPyth/PythonPack1/Prg1.py", line 3, in <module>     
driver=webdriver("C:\Python34\Lib\site-packages\selenium\webdriver\chromedriver.exe") 
TypeError: 'module' object is not callable. 

我的脚本很简单:

from selenium import webdriver   
driver=webdriver.Chrome("C:\Python34\Lib\site-packages\selenium\webdriver\chromedriver.exe")

推荐答案

根据最佳实践,您不得添加/删除/<强>修改任何目录/子目录/文件Python创建,直到和除非您知道更改将如何影响 Python 的行为.

As per best practices you must not add/delete/modify any of the directories / sub-directories / files created by Python until and unless you are aware how the change is going to effect Python's behavior.

您需要从下载最新的ChromeDriverChromeDriver - 适用于 Chrome 的 WebDriver 并将其存储在您系统中的任何位置.当您使用 Windows 操作系统 时,解压缩二进制文件并执行以下操作:

You need to download the latest ChromeDriver from ChromeDriver - WebDriver for Chrome and store it anywhere within your system. As you are on Windows OS, unzip the binary and perform the following:

  • 确保您正在调用:

  • Ensure that you are invoking:

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

  • 在您的程序中,将 Key executable_pathValue 一起传递给绝对路径 ChromeDriver 的.

  • Within your program, pass the Key executable_path along with the Value referring to the absolute path of the ChromeDriver.

    所以你的代码块将是:

    from selenium import webdriver
    
    driver=webdriver.Chrome(executable_path=r'C:UsersAninditachromedriver.exe')
    

  • 这篇关于TypeError: 'module' object is not callable error with driver=webdriver("C:\Python34\Lib\site-packages\selenium\webdriver\chromedriver.exe")的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

    查看全文
    相关文章
    登录 关闭
    扫码关注1秒登录
    发送“验证码”获取 | 15天全站免登陆