最近在写一个Python程序的时候,使用from selenium import webdriver,在run的时候却出现ImportError: cannot import name webdriver的提示,但是在Python IDLE里面跑却没有错误。很是疑惑,谷歌一下才发现有人已经在stackoverflow里面提出类似问题了,原因如下,在当前目录有个明教selenium的文件,Python会先导入这个文件,然后再导入标准库里面的selenium.py可以使用import selenium print selenium.file去看打印出的文件路径,如果不是下面类似的C:\Python27\lib\site-packages\selenium-2.31.0-py2.7.egg\selenium__init__.pyc,需要把当前目录下的文件删除或者重命名。
解决ImportError: cannot import name webdriver
最新推荐文章于 2025-05-26 16:48:22 发布