意外的Selenium日志记录错误

时间:2016-04-29 21:08:09

标签: python python-2.7 selenium

我一直在研究一些网络扫描应用程序,包括在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'

再次,要明确这些进口在以前完美运作,我没有做任何改变。感觉有更大的事情发生,我会喜欢任何观点或疑难解答提示。

谢谢!

1 个答案:

答案 0 :(得分:1)

我想出来了。问题是我在同一目录中有一个名为“logging.py”的文件。 Selenium试图加载日志记录模块,它正在加载我的文件而不是实际的模块。这就是导致错误的原因。

我通过将logging.py重命名为其他内容来解决问题。