简体   繁体   中英

“ImportError: No module named sendgrid” for SendGrid in Google App Engine

I followed the instruction from the https://cloud.google.com/appengine/docs/python/mail/sendgrid?hl=en and added SendGrid email support to my project.

It works perfectly on the development server but when I deploy to GAE I get “ImportError: No module named sendgrid”

I know the files are on the server (I downloaded source back from GAE to test it) and I have other third party libraries that work but not the sendgrid.

I spoke to SendGrid tech support but they point back to Google.

Here is the import line from main.py

from sendgrid import SendGridClient, Mail

The project directory structure looks like this:

-+
 |
 +sendgrid
 +smtpapi
 main.py

UPDATE:

After deleting everything and adding it back bit by bit I've finally discovered what was wrong.

I had a folder for static content called "s". I didn't mentioned it because I thought it was irrelevant. After deleting this folder - sendgrid suddenly started to work. Eventually, I've changed "s" to a longer name that does not starts with "s" and problem has disappeared.

install the sendgrid module in ur virtual environment using the following command

pip install sendgrid

or else u can install it as system wide module by typing

sudo apt-get install sendgrid

see how I solved it. 在此处输入图片说明

I had a folder for static content called "s" which I didn't mention in the question because I thought it was irrelevant. After I renamed this folder everything started to work. So the issue has been resolved, however the cause of it still remains a mystery ...

pip install sendgrid

Collecting sendgrid Cache entry deserialization failed, entry ignored Downloading https://files.pythonhosted.org/packages/b4/c6/d1ff0214c758d49bbc4b3761dae6d5653c3aea801ba49a9c94cc1fbf7980/sendgrid-6.4.7-py3-none-any.whl (73kB) 100% |████████████████████████████████| 81kB 952kB/s Collecting starkbank-ecdsa>=1.0.0 (from sendgrid) Cache entry deserialization failed, entry ignored Downloading https://files.pythonhosted.org/packages/4c/48/29de0f3876d8f89906372da49f132e5c5e46e2fa601a198a9eca6402f646/starkbank-ecdsa-1.1.0.tar.gz Collecting python-http-client>=3.2.1 (from sendgrid) Cache entry deserialization failed, entry ignored Downloading https://files.pythonhosted.org/packages/d9/93/fffa7a16e735ae8b946a58e2521e71180803440edc2a0de0d2e9d4a93b84/python_http_client-3.3.1.tar.gz Installing collected packages: starkbank-ecdsa, python-http-client, sendgrid Running setup.py install for starkbank-ecdsa ... done Running setup.py install for python-http-client ... done Successfully installed python-http-client-3.3.1 sendgrid-6.4.7 starkbank-ecdsa-1.1.0 You are using pip version 9.0.1, however version 20.2.4 is available. You should consider upgrading via the 'python -m pip install --upgrade pip' command.

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM