#!/usr/bin/env python
#! coding:UTF-8
import urllib2
import base64
import zlib
import json
import sys
import ssl
import datetime
import sendgrid
import sqlalchemy
from sqlalchemy import*
import ibm_db_sa.ibm_db_sa
db2 = sqlalchemy.create_engine('ibm_db_sa://dash013754:[email protected]:50000/BLUDB')
metadata=MetaData()
users=Table('users',metadata,
Column ('user_id', Integer, primary_key=True),
Column ('user_name', String(16), nullable=False),
Column('email_address', String(60), key='email',
Column ('password', String(20), nullable=False)
)
metadata.bind=db2
metadata.create_all()
users_table=Table('users', metadata, autoload=True, autoload_with=db2)
users_table
# using SendGrid's Python Library - https://github.com/sendgrid/sendgrid-python
sg = sendgrid.SendGridClient(api_user, api_key)
message = sendgrid.Mail()
message.add_to ("[email protected]")
message.set_from("[email protected]")
message.set_subject("Sending with SendGrid is Fun")
message.set_html(stmt)
sg.send(message)
When you attempt to deploy the ,
Traceback (most recent call last):
File "server.py", line 10, in
import sendgrid
ImportError: No module named sendgrid
It falls off with .How can I install sendgrid on Bluemix?Please let me know
python bluemix
I think you ran the pip install sendgrid
and other commands when you started using sendgrid because your environment doesn't have that package.The same can be said on Bluemix, so installation is required as you say.
For Bluemix, this seems to be done by describing dependencies in requirements.txt.
http://www.ibm.com/developerworks/jp/cloud/library/cl-worldbank-charting-app/
Add the requirement.txt file to the root directory of the project.The requirement.txt file must contain all external dependencies (such as Django and PyMongo) required to run the graph generation application.Bluemix ensures that when this application runs, the requisition.txt file will be read and the dependencies listed in this file will be installed.
The requirements.txt can be used in Heroku, etc., and you will find many documents in Japanese.
Various packages, including sendgrid, are registered with the site PyPi. pip install
or easy_install
will check and install the latest version from this site.
https://pypi.python.org/pypi/sendgrid
In this case, there is no sendgrid package on Bluemix, so you will have to install the sendgrid package on PyPi.Then, requirements.txt will indicate which package to choose.
Therefore, you will need to describe the version of sendgrid you want to use on Bluemix.
If you want to specify the same version that you are using, you can use the pip freeze
command to print a list that is compatible with requirements.txt.Read the article below.
Python Tips: I want to install my libraries together - Life with Python
577 Who developed the "avformat-59.dll" that comes with FFmpeg?
574 rails db:create error: Could not find mysql2-0.5.4 in any of the sources
925 When building Fast API+Uvicorn environment with PyInstaller, console=False results in an error
618 GDB gets version error when attempting to debug with the Presense SDK (IDE)
© 2024 OneMinuteCode. All rights reserved.