我一直在开发一些 Web 扫描应用程序,包括在 Raspberry Pi 上运行的 Selenium 和 Python 2.7。该应用程序运行完美,然后离开几分钟,现在不行了。
问题似乎与 Selenium 导入有关,我没有对这些文件进行任何更改。这是我看到的:
基本的 Python 导入:
from selenium import webdriver
from selenium.webdriver.common.by import By
from selenium.webdriver.support.ui import WebDriverWait
from selenium.webdriver.support import expected_conditions as EC
from selenium.webdriver.support.ui import Select
该代码始终会产生以下结果:
2016-04-29 17:01:23.428942
Traceback (most recent call last):
File "./testing.py", line 1, in <module>
from selenium import webdriver
File "/usr/local/lib/python2.7/dist-packages/selenium/webdriver/__init__.py", line 18, in <module>
from .firefox.webdriver import WebDriver as Firefox
File "/usr/local/lib/python2.7/dist-packages/selenium/webdriver/firefox/webdriver.py", line 34, in <module>
from .remote_connection import FirefoxRemoteConnection
File "/usr/local/lib/python2.7/dist-packages/selenium/webdriver/firefox/remote_connection.py", line 18, in <module>
from selenium.webdriver.remote.remote_connection import RemoteConnection
File "/usr/local/lib/python2.7/dist-packages/selenium/webdriver/remote/remote_connection.py", line 34, in <module>
from . import utils
File "/usr/local/lib/python2.7/dist-packages/selenium/webdriver/remote/utils.py", line 26, in <module>
LOGGER = logging.getLogger(__name__)
AttributeError: 'module' object has no attribute 'getLogger'
再次声明,这些导入之前工作正常,我没有做任何更改。感觉好像有更重要的事情在发生,我会喜欢任何观点或故障排除技巧。
谢谢!
最佳答案
我想通了。问题是我在同一目录中有一个名为“logging.py”的文件。 Selenium 试图加载日志模块,它正在加载我的文件而不是实际的模块。这就是导致错误的原因。
我通过将 logging.py 重命名为其他名称解决了这个问题。
关于python - 意外的 Selenium 日志记录错误,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/36947462/