ImportError:没有名为django.core.mail的模块

时间:2022-04-12 23:15:31

I tried to enable the email functionality of edx, and I followed these steps.

我尝试启用edx的电子邮件功能,然后按照这些步骤操作。

  1. To get the emails working, all you have to do is the following,

    要使电子邮件正常工作,您所要做的就是以下内容,

  2. Go to cms\envs\common.py

    转到cms \ envs \ common.py

  3. Go to the email portion. Should start with a comment, # Email.

    转到电子邮件部分。应该从评论开始,#Email。

  4. Change EMAIL_BACKEND to 'django.core.mail.backends.smtp.EmailBackend'

    将EMAIL_BACKEND更改为“django.core.mail.backends.smtp.EmailBackend”

  5. Change the DEFAULT_FROM_EMAIL to the email you want to use. Similarly,

    将DEFAULT_FROM_EMAIL更改为您要使用的电子邮件。同样的,

  6. for DEFAULT_FEEDBACK_EMAIL and SERVER_EMAIL 

    对于DEFAULT_FEEDBACK_EMAIL和SERVER_EMAIL

  7. Set EMAIL_HOST to the host of your choice. (e.g - 'smtp.google.com' for Gmail.)

    将EMAIL_HOST设置为您选择的主机。 (例如 - 适用于Gmail的'smtp.google.com'。)

  8. Set EMAIL_HOST_USER to your email id and EMAIL_HOST_PASSWORD to your password.

    将EMAIL_HOST_USER设置为您的电子邮件ID,将EMAIL_HOST_PASSWORD设置为您的密码。

  9. Set EMAIL_PORT to the port your server uses (587 for Gmail.)

    将EMAIL_PORT设置为服务器使用的端口(Gmail为587)。

  10. Set EMAIL_USE_TLS to True or False according to your server. (True for Gmail.)

    根据您的服务器将EMAIL_USE_TLS设置为True或False。 (对于Gmail来说是真的。)

However, when I tried to make a test like this:

但是,当我尝试进行这样的测试时:

>>> from django.core.mail import EmailMessage
>>> email = EmailMessage('Hello', 'World', to=['youremail@somewhere.com'])
>>> email.send()

the error occured:

发生错误:

Traceback (most recent call last):
 File "<stdin>", line 1, in <module
ImportError: No module named django.core.mail

I'm a beginner and I've no idea about how to solve this. I've tried to search for solution on the internet and on the websites of Django and edx, but I still don't even have a clue. Could anyone help me with this please? Much appreciate.

我是初学者,我不知道如何解决这个问题。我试图在互联网和Django和edx的网站上搜索解决方案,但我仍然没有线索。有人可以帮我这个吗?非常感谢。

1 个解决方案

#1


0  

Probably your PYTHONPATH variable is not set correctly. Start django like this:

可能您的PYTHONPATH变量设置不正确。像这样开始django:

./manage.py shell

and try this command:

并尝试此命令:

import django

If this raises an error, you need to set your PYTHONPATH environment variable in a way that it contains the path to your django directory.

如果这会引发错误,则需要以包含django目录路径的方式设置PYTHONPATH环境变量。

#1


0  

Probably your PYTHONPATH variable is not set correctly. Start django like this:

可能您的PYTHONPATH变量设置不正确。像这样开始django:

./manage.py shell

and try this command:

并尝试此命令:

import django

If this raises an error, you need to set your PYTHONPATH environment variable in a way that it contains the path to your django directory.

如果这会引发错误,则需要以包含django目录路径的方式设置PYTHONPATH环境变量。