Imapclient TypeError

I’m new to programming. I’m trying to reproduce some code from a book, but got stuck after just a pair of lines here:

import imapclient

after running this next error shows up:

Traceback (most recent call last):
File "C:/Users/vinni/AppData/Local/Programs/Python/Python39/", line 2, in
File "C:\Users\vinni\AppData\Local\Programs\Python\Python39\lib\site-packages\imapclient\", line 254, in  **init**
self._imap = self._create_IMAP4()
File "C:\Users\vinni\AppData\Local\Programs\Python\Python39\lib\site-packages\imapclient\", line 288, in _create_IMAP4
return tls.IMAP4_TLS(, self.port, self.ssl_context,
File "C:\Users\vinni\AppData\Local\Programs\Python\Python39\lib\site-packages\imapclient\", line 44, in  **init**
imaplib.IMAP4. **init** (self, host, port)
File "C:\Users\vinni\AppData\Local\Programs\Python\Python39\lib\", line 202, in  **init**, port, timeout)
TypeError: open() takes 3 positional arguments but 4 were given

I tried it with different imap servers, tried reinstalling imapclient, but nothing seems to work. My Python version is 3.9.0.
What might cause this error?

Hi @Tititun,

Welcome to the Streamlit Community! It looks like your question doesn’t have to do with Streamlit but with the python’s imapclient package. Unfortunately, I personally have never used this particular python package myself, but you to have a pretty standard error displaying: TypeError: open() takes 3 positional arguments but 4 were given. This indicates that when you call the imapclient.IMAPClient it is unhappy with the arguments you have supplied (the '',ssl=True portion in the brackets).

I have linked the documentation for imapclient for you, they have an example on this page of using that function. Hopefully this helps!

Happy Streamlit-ing!

Using Python 3.8 fixed this issue for me.
Version 3.9 breaks imapclient module for some reason.