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
imapObj=imapclient.IMAPClient('imap.mail.ru',ssl=True)

after running this next error shows up:

Traceback (most recent call last):
File "C:/Users/vinni/AppData/Local/Programs/Python/Python39/getMail.py", line 2, in
imapObj=imapclient.IMAPClient('imap.mail.ru',ssl=True)
File "C:\Users\vinni\AppData\Local\Programs\Python\Python39\lib\site-packages\imapclient\imapclient.py", line 254, in  **init**
self._imap = self._create_IMAP4()
File "C:\Users\vinni\AppData\Local\Programs\Python\Python39\lib\site-packages\imapclient\imapclient.py", line 288, in _create_IMAP4
return tls.IMAP4_TLS(self.host, self.port, self.ssl_context,
File "C:\Users\vinni\AppData\Local\Programs\Python\Python39\lib\site-packages\imapclient\tls.py", line 44, in  **init**
imaplib.IMAP4. **init** (self, host, port)
File "C:\Users\vinni\AppData\Local\Programs\Python\Python39\lib\imaplib.py", line 202, in  **init**
self.open(host, 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 'imap.mail.ru',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!
Marisa