Sendgrid-python: 6.4.0 version throws exceptions in Azure Functions

Created on 24 Jun 2020  路  10Comments  路  Source: sendgrid/sendgrid-python

Issue Summary

Our code which was working with the last version of SendGrid throws exception about "No module named 'ellipticcurve' when Azure Python Function is invoked.

Steps to Reproduce

  1. Deploy to Azure using requirements.txt (either sendgrid or sendgrid==6.4.0)
  2. Invoke Azure Function that imports SendGridAPIClient
  3. Exception is thrown: "Result: Failure Exception: ModuleNotFoundError: No module named 'ellipticcurve'."

Code Snippet

from sendgrid import SendGridAPIClient
from sendgrid.helpers.mail import Mail
import logging
import os
...
...
...

Exception/Log

Result: Failure Exception: ModuleNotFoundError: No module named 'ellipticcurve'. 

Troubleshooting Guide: https://aka.ms/functions-modulenotfound
Stack: 
File "/azure-functions-host/workers/python/3.7/LINUX/X64/azure_functions_worker/dispatcher.py", line 259, in _handle__function_load_request func_request.metadata.entry_point)
File "/azure-functions-host/workers/python/3.7/LINUX/X64/azure_functions_worker/utils/wrappers.py", line 31, in call raise extend_exception_message(e, message)
File "/azure-functions-host/workers/python/3.7/LINUX/X64/azure_functions_worker/utils/wrappers.py", line 29, in call return func(*args, **kwargs)
File "/azure-functions-host/workers/python/3.7/LINUX/X64/azure_functions_worker/loader.py", line 73, in load_function mod = importlib.import_module(fullmodname) 
File "/usr/local/lib/python3.7/importlib/__init__.py", line 127, in import_module return _bootstrap._gcd_import(name[level:], package, level)
File "/home/site/wwwroot/MyTesting/__init__.py", line 19, in <module> from .sendgrid import sendemail
File "/home/site/wwwroot/MyTesting/sendgrid/sendemail.py", line 1, in <module> from sendgrid import SendGridAPIClient
File "/home/site/wwwroot/.python_packages/lib/site-packages/sendgrid/__init__.py", line 21, in <module> from .helpers.eventwebhook import * # noqa
File "/home/site/wwwroot/.python_packages/lib/site-packages/sendgrid/helpers/eventwebhook/__init__.py", line 1, in <module> from ellipticcurve.ecdsa import Ecdsa

Technical details:

  • sendgrid-python version: 6.4.0
  • python version: 3.7
bug

Most helpful comment

Patch release published: 6.4.1

All 10 comments

Adding sendgrid==6.3.1 (in the requirements.txt) is the workaround that we plan to use for now.

Opened a PR to add the required dependency to the package requirements. Thanks for catching this!

Faced the same error in Ubuntu 18.04 while using in my flask app after updating to 6.4.0
It was working perfectly in the previous version

Updated using the command

pip install sendgrid --upgrade

Collecting sendgrid
  Downloading sendgrid-6.4.0-py3-none-any.whl (73 kB)
     |鈻堚枅鈻堚枅鈻堚枅鈻堚枅鈻堚枅鈻堚枅鈻堚枅鈻堚枅鈻堚枅鈻堚枅鈻堚枅鈻堚枅鈻堚枅鈻堚枅鈻堚枅鈻堚枅| 73 kB 97 kB/s 
Requirement already satisfied, skipping upgrade: python-http-client>=3.2.1 in ./p37ve/lib/python3.6/site-packages (from sendgrid) (3.2.7)
Installing collected packages: sendgrid
  Attempting uninstall: sendgrid
    Found existing installation: sendgrid 6.3.1
    Uninstalling sendgrid-6.3.1:
      Successfully uninstalled sendgrid-6.3.1
Successfully installed sendgrid-6.4.0

After running the flask app, I get the following error

Error: While importing "flaskapp.run", an ImportError was raised:

Traceback (most recent call last):
  File "/media/blactrojan/Non-OS partition/BlacTROJAN/Git Repos/Repo-FlaskCyndrome/flaskapp/p37ve/lib/python3.6/site-packages/flask/cli.py", line 235, in locate_app
    __import__(module_name)
  File "/media/blactrojan/Non-OS partition/BlacTROJAN/Git Repos/Repo-FlaskCyndrome/flaskapp/run.py", line 15, in <module>
    from sendgrid import SendGridAPIClient
  File "/media/blactrojan/Non-OS partition/BlacTROJAN/Git Repos/Repo-FlaskCyndrome/flaskapp/p37ve/lib/python3.6/site-packages/sendgrid/__init__.py", line 21, in <module>
    from .helpers.eventwebhook import * # noqa
  File "/media/blactrojan/Non-OS partition/BlacTROJAN/Git Repos/Repo-FlaskCyndrome/flaskapp/p37ve/lib/python3.6/site-packages/sendgrid/helpers/eventwebhook/__init__.py", line 1, in <module>
    from ellipticcurve.ecdsa import Ecdsa
ModuleNotFoundError: No module named 'ellipticcurve'

Technical details:

sendgrid version: 6.4.0
python version: 3.7

A PATCH version should be released to fix the issue

Faced the same error in Ubuntu 18.04 while using in my flask app after updating to 6.4.0
It was working perfectly in the previous version

Updated using the command

pip install sendgrid --upgrade

Collecting sendgrid
  Downloading sendgrid-6.4.0-py3-none-any.whl (73 kB)
     |鈻堚枅鈻堚枅鈻堚枅鈻堚枅鈻堚枅鈻堚枅鈻堚枅鈻堚枅鈻堚枅鈻堚枅鈻堚枅鈻堚枅鈻堚枅鈻堚枅鈻堚枅鈻堚枅| 73 kB 97 kB/s 
Requirement already satisfied, skipping upgrade: python-http-client>=3.2.1 in ./p37ve/lib/python3.6/site-packages (from sendgrid) (3.2.7)
Installing collected packages: sendgrid
  Attempting uninstall: sendgrid
    Found existing installation: sendgrid 6.3.1
    Uninstalling sendgrid-6.3.1:
      Successfully uninstalled sendgrid-6.3.1
Successfully installed sendgrid-6.4.0

After running the flask app, I get the following error

Error: While importing "flaskapp.run", an ImportError was raised:

Traceback (most recent call last):
  File "/media/blactrojan/Non-OS partition/BlacTROJAN/Git Repos/Repo-FlaskCyndrome/flaskapp/p37ve/lib/python3.6/site-packages/flask/cli.py", line 235, in locate_app
    __import__(module_name)
  File "/media/blactrojan/Non-OS partition/BlacTROJAN/Git Repos/Repo-FlaskCyndrome/flaskapp/run.py", line 15, in <module>
    from sendgrid import SendGridAPIClient
  File "/media/blactrojan/Non-OS partition/BlacTROJAN/Git Repos/Repo-FlaskCyndrome/flaskapp/p37ve/lib/python3.6/site-packages/sendgrid/__init__.py", line 21, in <module>
    from .helpers.eventwebhook import * # noqa
  File "/media/blactrojan/Non-OS partition/BlacTROJAN/Git Repos/Repo-FlaskCyndrome/flaskapp/p37ve/lib/python3.6/site-packages/sendgrid/helpers/eventwebhook/__init__.py", line 1, in <module>
    from ellipticcurve.ecdsa import Ecdsa
ModuleNotFoundError: No module named 'ellipticcurve'

Technical details:

sendgrid version: 6.4.0
python version: 3.7

Facing the same problem

Facing the same problem too. What's the official workaround until the patch is released?

To not upgrade

To problem was, my Dockerfile was installing the latest Sendgrid by default. As someone suggested, I added a requirements.txt file and set the version to 6.3.1 to work around it for now.

For ModuleNotFoundError: No module named 'ellipticcurve' run pip install starkbank-ecdsa

Patch release published: 6.4.1

Was this page helpful?
0 / 5 - 0 ratings