TypeError:“模块"对象无法通过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")
问题描述
我在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.
您需要从下载最新的 ChromeDriver ChromeDriver-适用于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_path 以及 Value 来引用绝对路径 > 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:\Users\Anindita\chromedriver.exe')
这篇关于TypeError:“模块"对象无法通过driver = webdriver调用("C:\\ Python34 \\ Lib \\ site-packages \\ selenium \\ webdriver \\ chromedriver.exe")的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!