2016-04-29 127 views
2

我一直在研究一些網絡掃描應用程序,包括運行在Raspberry Pi上的Selenium和Python 2.7。該應用程序工作完美,然後走了幾分鐘,現在不是。意外的硒日誌記錄錯誤

這個問題似乎與硒進口和我沒有改變這些文件。這是我所看到的:

基本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' 

再次,要清楚前,我這些進口是完全工作沒有做任何改變。感覺就像有更大的事情發生,我會喜歡任何觀點或疑難解答提示。

謝謝!

+0

冉你的代碼,看起來不錯。我猜你有另一個文件..其他代碼?我將你的五行放入'test.py'中,並且安裝了'selenium'的pip就像一個魅力一樣。 –

+0

愚蠢的問題:你有'LOGGER = logging.getLogger(__ name __)'''導入日誌記錄? –

+0

這是奇怪的地方。我的文件test.py只包含那5個輸入 - 僅此而已,但它會拋出錯誤。它只是在幾個小時前完美運行... –

回答

1

我明白了這一點。問題是我在同一個目錄下有一個名爲「logging.py」的文件。 Selenium試圖加載日誌記錄模塊,它正在加載我的文件而不是實際的模塊。這是造成錯誤的原因。

我通過將logging.py重命名爲別的方法解決了這個問題。