我在 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")
As per 最佳实践你不能add/delete/modify任何一个目录 / 子目录 / files由...制作Python直到并且除非您知道更改将如何影响Python's行为。
您需要下载最新的Chrome驱动程序 from ChromeDriver - 适用于 Chrome 的 WebDriver https://sites.google.com/a/chromium.org/chromedriver/downloads并将其存储在系统中的任何位置。当你在Windows操作系统,解压缩二进制文件并执行以下操作:
-
确保您正在调用:
driver = webdriver.Chrome() # not webdriver.chrome()
在您的程序中,传递Key 可执行文件路径随着Value指的是绝对路径 of the Chrome驱动程序.
- 在提到绝对路径 of the Chrome驱动程序,或者使用双反斜杠 i.e.
\\
在双引号内,即" "
- Or use 单反斜杠 i.e.
\
在单引号内,即' '
连同原始的r
切换如下。
-
所以你的代码块将是:
from selenium import webdriver
driver=webdriver.Chrome(executable_path=r'C:\Users\Anindita\chromedriver.exe')
本文内容由网友自发贡献,版权归原作者所有,本站不承担相应法律责任。如您发现有涉嫌抄袭侵权的内容,请联系:hwhale#tublm.com(使用前将#替换为@)