ImportError: No module named helpers.mail
Issue Summary
ImportError: No module named helpers.mail when I'm run this code on my machine. i've followed all steps which are described in the Integration kit.
Sample Code:
import sendgrid import os from sendgrid.helpers.mail import *
sg = sendgrid.SendGridAPIClient(apikey=os.environ.get('SENDGRID_API_KEY')) from_email = Email("[email protected]") to_email = Email("[email protected]") subject = "Sending with SendGrid is Fun" content = Content("text/plain", "and easy to do anywhere, even with Python") mail = Mail(from_email, subject, to_email, content) response = sg.client.mail.send.post(request_body=mail.get()) print(response.status_code) print(response.body) print(response.headers)
Technical details:
- sendgrid-python Version: 5.0.0
- Python Version: 2.7.6
Hello @ervaibhavsinghal,
Unfortunately, I can not reproduce this. Here are the steps I took:
mkdir test5
cd test5
virtualenv env
source env/bin/activate
pip install sendgrid
Then I created test.py with the code provided above and added my own emails.
python test.py
And the email was sent.
Please review and let me know if there are any differences in our setup.
Thanks!
With Best Regards,
Elmer
@thinkingserious I've already used these steps and faced this issue.
Hi @ervaibhavsinghal,
Can you please try retracing and logging your steps so I can compare with mine?
Also, what operating system are you using?
With Best Regards,
Elmer
@thinkingserious actually I'm working on node js API but this is not working, so I thought to test the same API in python, it's working now in a python. Thanks but in node it's not working.
Hello, having the exact same issue !
I am able to run the same code find on a VM on OS X. But on our ububunt 16 machine I have the same error. I did pip uinstall sendgrid and then pip install sendgrid to make sure current version ...
Oddly if I run python by hand I do not see the issue, only when I run my script ...
ok issue was naturally my environment variable PATH which had some things out of order. Once I sorted that out all worked. I suggest folks clear the PATH variable and add stuff back in slowly once they get send grid working. standard type of issue
Awesome, I'm glad you got it sorted and thanks for following up!
Just ran into this issue and it was driving me crazy. I could not figure out why this was happening. Fast forward 2 hours later when I realized that I made the mistake of naming my file sendgrid.py

Everything works when you name your file anything else - in case anyone runs into the same issue.
Thanks for all the great work on this library - much appreciated!!
Thank you @hidace!
hhaha, my file name is "sendgrid.py" and this is the reason
Same issue!
Runs ok on a virtualenv fwiw
Installing collected packages: python-http-client, sendgrid
Running setup.py install for python-http-client ... done
Successfully installed python-http-client-3.1.0 sendgrid-5.6.0
➜ ✗ pip freeze | grep sendgrid
sendgrid==5.6.0
➜ git:(master) ✗ python3
Type "help", "copyright", "credits" or "license" for more information.
import sendgrid Traceback (most recent call last): File "
", line 1, in ModuleNotFoundError: No module named 'sendgrid'
Just ran into this issue and it was driving me crazy. I could not figure out why this was happening. Fast forward 2 hours later when I realized that I made the mistake of naming my file sendgrid.py
Everything works when you name your file anything else - in case anyone runs into the same issue.
Thanks for all the great work on this library - much appreciated!!
SAME HERE!!!!
Just ran into this issue and it was driving me crazy. I could not figure out why this was happening. Fast forward 2 hours later when I realized that I made the mistake of naming my file sendgrid.py
Everything works when you name your file anything else - in case anyone runs into the same issue. Thanks for all the great work on this library - much appreciated!!
SAME HERE!!!!
Can i suggest a line at the top of the file to save people trying it some headache.
assert __file__ != "sendgrid.py", "Err: Can't call your script the same as the sendgrid.py module"