AttributeError:通过PyCharm使用selenium webdriver的模块“selenium”没有属性“webdriver”

2024-04-19 15:26:18 发布

您现在位置:Python中文网/ 问答频道 /正文

我的翻译是Python。Selenium安装成功,当我使用Jupyter Notebook时可以访问它的webdriver,但是当我尝试在PyCharm中运行相同的代码时,它说: AttributeError:模块“selenium”没有属性“webdriver” 如下所示: PyCharm not detecting selenium webdriver

我已经检查了我的项目解释器设置,Selenium出现在列表中,如下所示: Selenium appears to be installed in PyCharm

然后我点击Selenium打开这个窗口,并按照建议安装它: install seleniumselenium installed PyCharm在这之后进行索引。有一段时间,webdriver import下没有红线,但在运行该文件时,我收到sae的旧消息,说: AttributeError:模块“selenium”没有属性“webdriver”

顺便说一句,我也尝试过使用alt+Enter,它安装了这个包,但是没有任何好处。总是这样。 同样的问题也出现在Spyder身上。webdriver在那里也无法访问。 我做了无数次都没有成功。在


Tags: 模块项目代码import列表属性seleniumjupyter
2条回答

当使用PythonSelenium模块时,不应使用Selenium作为文件名或用户定义的变量,因为它是关键字/保留字。使用so可以创建^{}。在

解决方案

将文件名从selenium.py重命名为mySelenium.py并执行测试。在

尝试更改文件名,使用run.py或其他文件名,而不是selenium.py。在

相关问题 更多 >