ImportError: No module named **** Error in google app engine
Asked Answered
B

3

6

I am developing my application in google app engine now i am using Google Cloud SQL. It runs at localhost perfectly,, But when i am deploying my application to server it gives me following error.

ImportError: No module named MySQLdb

Later i have copied MySQLdb package to application directory. Now it is giving me error

ImportError: No module named _mysql.

What i am doing wrong here , Any guideline ?

Besse answered 19/2, 2013 at 10:33 Comment(1)
Have you find some solution/workaround yet?Unstable
K
7

MySQLdb might be missing in your app.yaml. This library should be there so that Google App Engine loads it for your instance. Hope this will help.

libraries:
- name: MySQLdb
  version: "latest"
Kerstinkerwin answered 10/12, 2013 at 10:4 Comment(0)
U
0

Looking at the docs that does not seem to be how you do it at all.

Building an application with a local MySQL instance

from google.appengine.api import rdbms

CLOUDSQL_INSTANCE = ''
DATABASE_NAME = 'guestbook'
USER_NAME = 'username'
PASSWORD = 'password'


def get_connection():
    return rdbms.connect(instance=CLOUDSQL_INSTANCE, database=DATABASE_NAME,
                         user=USER_NAME, password=PASSWORD, charset='utf8')
Unciform answered 19/2, 2013 at 10:37 Comment(5)
what tutorial are you following?Unciform
Using developers.google.com/appengine/training/cloud-sql/…Besse
try deleting the mysql package before you deploy it? I never had this problem but I only quickly looked at this when it first came out.Unciform
When i am deleting MySQLdb package from application directory i getting ImportError: No module named MySQLdb errorBesse
Once a better answer comes along I'll delete this one as it's obviously not helping you solve this.Unciform
S
0

This tutorial got my app eventually working...

What I did: I created a very basic project (just one simple app with one model) and followed above tutorial to get it working in my development environment and on GAE. Then migrated my code from my old (non-GAE) project to the new project. All was fine.

The bad news: it still takes some effort getting a new project properly deployed on GAE and Cloud SQL. I have never managed to get it working in one go. You have to really scrutinise the GAE logs.

Storey answered 20/2, 2013 at 1:26 Comment(0)

© 2022 - 2024 — McMap. All rights reserved.