sabuhish / fastapi-mail

Fastapi mail system sending mails(individual, bulk) attachments(individual, bulk)
https://sabuhish.github.io/fastapi-mail/
MIT License
673 stars 82 forks source link

ImportError: cannot import name 'MessageType' from 'fastapi_mail' #175

Closed mvadrev closed 1 year ago

mvadrev commented 1 year ago

Hey Guys,

I am following the tutorial from the website to send an email. But I am getting this error:

` from fastapi_mail import FastMail, MessageSchema, ConnectionConfig, MessageType ImportError: cannot import name 'MessageType' from 'fastapi_mail'

`

It was working fine a few weeks ago. I am trying to dockerize a fastapi container and this is happening when I run my docker container. I have already included pip install fastapi and fastapi-mail. Any help will be appreciated.

mvadrev commented 1 year ago

Dependency issues. Removed versions from req.txt and worked. Originally the re were written by pip freeze -> requirements and were somehow not working

KonstantinKlepikov commented 11 months ago

@mvadrev this still here

Traceback (most recent call last):
  File "/app/app/core/email.py", line 2, in <module>
    from fastapi_mail import (
  File "/usr/local/lib/python3.10/site-packages/fastapi_mail/__init__.py", line 1, in <module>
    from fastapi_mail.config import ConnectionConfig
  File "/usr/local/lib/python3.10/site-packages/fastapi_mail/config.py", line 3, in <module>
    from aiosmtplib.api import DEFAULT_TIMEOUT
  File "/usr/local/lib/python3.10/site-packages/aiosmtplib/__init__.py", line 12, in <module>
    from .api import send
  File "/usr/local/lib/python3.10/site-packages/aiosmtplib/api.py", line 4, in <module>
    import email.message
  File "/app/app/core/email.py", line 2, in <module>
    from fastapi_mail import (
ImportError: cannot import name 'FastMail' from partially initialized module 'fastapi_mail' (most likely due to a circular import) (/usr/local/lib/python3.10/site-packages/fastapi_mail/__init__.py)

poetry:

fastapi-mail = {extras = ["aioredis"], version = "1.4.1"}

KonstantinKlepikov commented 11 months ago

ups, never use names of files in your app, that similar to email or something like. Is great chance to get circular import error. :)