Protonmail doesn't yet support Python 3.12
markmcwiggins opened this issue · 2 comments
There's a line in the 3.11 code that uses
input.read(file)
instead of just
input(file)
I don't understand which input.read(file)
you are talking about, but on Python 3.12 the installation fails due to not all libraries being updated yet. The aiohttp
library cannot be installed due to an error in the multidict
library
But using this answer, you can set the environment variable MULTIDICT_NO_EXTENSIONS=1
and then everything will work:
Windows:
$Env:MULTIDICT_NO_EXTENSIONS=1
Linux:
export MULTIDICT_NO_EXTENSIONS=1
Then everything is as usual:
- Installation:
pip install protonmail-api-client
playwright install webkit
- Use:
from protonmail import ProtonMail
username = "...@proton.me"
password = "..."
passphrase = '...'
pk = 'privatekey.....asc'
proton = ProtonMail()
proton.login(username, password)
proton.pgp_import(pk, passphrase=passphrase)
messages = proton.get_messages()
print(len(messages))
# I got:
# login success
# _async_get_messages: 100%|██████████| 2/2 [00:00<00:00, 5.60it/s]
# 172
This works for me, but don't forget that that answer says that the MULTIDICT_NO_EXTENSIONS=1
parameter slows down the library by 20-50 times, although I don't know if this matters in this project. I recommend staying on version 3.11 until all other libraries are updated.
Now all libraries are updated and everything works as normal.
You no longer need to use the MULTIDICT_NO_EXTENSIONS=1
option to use Python 3.12
Just:
pip install protonmail-api-client