[英]Code runs fine in pycharm, but when converted to exe it does not
[英]Code runs fine in PyCharm, returns 'AttributeError' when executed from the command line
我有一些 Python 代碼使用imaplib
從 gmail 帳戶檢索電子郵件,然后提取數據。 當我在 PyCharm 中執行我的代碼時,一切都按預期工作,如果我從命令行運行它,但是我得到以下AttributeError
:
模塊“imaplib”沒有屬性“IMAP4_SSL”
以下是相關代碼:
import imaplib
smtp_server = 'imap.gmail.com'
smtp_port = 993
imap_server = imaplib.IMAP4_SSL(smtp_server, smtp_port) # this line produces the error
可能相關的是,此代碼位於我的主文件正在導入的另一個.py 文件中。 我當然可以提供其他信息,我只是不確定還有什么相關的。
對於可能導致此問題的任何指示,我將不勝感激。
編輯:
如果我從 Anaconda 提示符運行程序,結果會按預期運行。
看來您在當前目錄中有一個名為imaplib.py
的文件。 請刪除該文件,並刪除生成的.pyc
文件
聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.