2016-08-17 74 views
0

我不斷收到此錯誤:<type 'exceptions.ImportError'> cannot import name get_cert_infos。 我很確定我正確地導入了一切。有問題的文件是participant.py,具有:web2py python - ImportError無法導入名稱

from datetime import date 

from widgets import SelectOrAdd, LabelSortedOptionsWidget, DynamicSelect, \ 
     AutocompleteReferenceWidget 
from communication import handle_notification, send_email 
from utility import create_temp_password, hash_password 

from export import get_cert_infos, build_certificate 

我有exports.pyget_cert_infosbuild_certificate方法做的有內部存在。我不明白問題是什麼。

我看了幾個其他職位上這一點,他們似乎都在說,這是最有可能是圓形的進口問題

我有export安裝和更新export==0.1.2

ImportError: Cannot import name X

+0

它是'export.py'或'exports.py'?無論如何,這個模塊是什麼?我們可以看到它嗎? – cdonts

回答

1

嘗試雙重檢查拼寫,我知道這是愚蠢的,但它發生。

,如果它不是,嘗試在出口編寫這個方法

def hello_world(): 
    print 'hello world' 

然後

import export 

export.hello_world() 

如果這樣的作品,它可能是一些錯誤的方法本身,如果沒有我想象名稱export被保留並且導致衝突(我的代碼編輯器不會將其標記爲保留的tho)。

是否有必要只導入這兩種方法?或者你可以導入整個模塊並像hello_world一樣使用所需的方法?這是否會導致你麻煩?如果你刪除get_cert_infos確實build_certificate給你帶來麻煩嗎?

+0

謝謝。事實證明,這是保留字'export'導致衝突。我導入導出並有一個名爲export.py的文件...導出覆蓋了我的export.py,因此沒有我需要的方法。我運行了一個'pip uninstall export',因爲我實際上並不需要它,它解決了我的問題。我將不得不重新命名該文件以避免未來的衝突。 – luckyging3r

相關問題