簡體   English   中英

當我像 Windows 服務一樣運行我的程序時,我得到一個“模塊‘imaplib’沒有屬性‘IMAP4_SSL’”

[英]I get a "module 'imaplib' has no attribute 'IMAP4_SSL'" when I run my program like windows service

我用 Python 制作了一個 Windows 服務來閱讀一些郵件並獲取一些信息。 當我在帶有 Pycharm 的 win7 開發人員機器上使用它時,它運行良好,但是當我嘗試在 Windows 2012 服務器上運行它時(這是它可以工作的地方),我收到“模塊‘imaplib’沒有屬性‘IMAP4_SSL’ ”

有趣的是,當我在服務器的 python 控制台中放置相同的命令時,它沒有給我任何錯誤。

代碼是:

    def open_imap():
        # Read the config file
        config2 = configparser.ConfigParser()
        config2.read(os.path.join('C:\\', 'IziPayMail.ini'))
        # Connect to the server
        hostname = config2.get('Mail', 'hostname')
        logging.info('Hostname = ' + hostname)
        connection = imaplib.IMAP4_SSL(hostname)
        logging.info('Conectado a ' + hostname)

        # Login to our account
        username = config2.get('Mail', 'username')
        password = config2.get('Mail', 'password')
        connection.login(username, password)
        logging.info('Logeado a ' + username)
        
        return connection

任何人都知道會發生什么?

克勞迪奧

經過多次嘗試,我發現我可以像運行 Windows Server 一樣運行它。 我也注意到它與 SSL 有關。 我累了,我將協議更改為沒有 SSL 的 IMAP ......現在它可以工作了。 我真的很想找到一個真正的答案,但現在使用 IMAP 有效。

暫無
暫無

聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.

 
粵ICP備18138465號  © 2020-2024 STACKOOM.COM