简体   繁体   中英

Getting “module 'imaplib' has no attribute 'IMAP4_SSL'” when using imaplib with cx_Freeze

I am using imaplib to read some emails. This code works without error within Pycharm. I have used cx_Freeze to make this program an executable, and now I get an error that traces back to cx_Freeze's startup.py. I have made an executable before, not with imaplib, and this kind of problem didn't happen.

There are other posts online about a "module imaplib has no attribute IMAP4_SSL", but these do not solve the problem and may have different causes than mine. Other causes for that statement involve virtual environments or things different than my situation.

The full error message is below:

Traceback (most recent call last):
 File "C:\Users\Todd\Desktop\Python\lib\site-packages\cx_Freeze\initscripts\__startup__.py", line 14, in run module.run() 
 File "C:\Users\Todd\Desktop\Python\lib\site-packages\cx_Freeze\initscrips\Console.py", line 26, in run exec(code, m.__dict__)
 File "Main.py", line 18, in <module>
 File 'C:Users\Todd\Desktop\ForStemotics\EmailGetter.py", line 43, in GetEmails
  mail = imaplib.IMAP4_SSL("imap.gmail.com")
AttributeError: module 'imaplib' has no attribute 'IMAP4_SSL'

EDIT in setup.py from comments:

from cx_Freeze import setup, Executable
setup(name = 'SARS', 
      version='0.1', 
      description = 'email automator', 
      executables = [Executable("Main.py")])

Thank you to all who contributed and viewed. I have solved the problem. After some experimenting I traced the problem to the ssl module. I couldn't find a way around this but I found another fix. I upgraded from python 3.7.1 to the latest version 3.7.3 and the problem stopped. I don't know why this is, but if anyone else was experiencing mine or a similar problem I would recommend this as something to try.

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM