500 Server Error on GAE - MySQLdb not loaded - python

I get a 500 Server Error while uploading my app on GAE. It works perfectly fine locally with dev_appserver with SETTINGS_MODE='prod'.
Based on the logs, it cannot find MySQLdb on GAE. It does not make sense to me.
Help!
Traceback (most recent call last):
File "/base/data/home/runtimes/python27/python27_lib/versions/1/google/appengine/runtime/wsgi.py", line 266, in Handle
result = handler(dict(self._environ), self._StartResponse)
File "/base/data/home/runtimes/python27/python27_lib/versions/third_party/django-1.5/django/core/handlers/wsgi.py", line 236, in __call__
self.load_middleware()
File "/base/data/home/runtimes/python27/python27_lib/versions/third_party/django-1.5/django/core/handlers/base.py", line 49, in load_middleware
mod = import_module(mw_module)
File "/base/data/home/runtimes/python27/python27_lib/versions/third_party/django-1.5/django/utils/importlib.py", line 35, in import_module
__import__(name)
File "/base/data/home/runtimes/python27/python27_lib/versions/third_party/django-1.5/django/contrib/auth/middleware.py", line 3, in <module>
from django.contrib.auth.backends import RemoteUserBackend
File "/base/data/home/runtimes/python27/python27_lib/versions/third_party/django-1.5/django/contrib/auth/backends.py", line 3, in <module>
from django.contrib.auth.models import Permission
File "/base/data/home/runtimes/python27/python27_lib/versions/third_party/django-1.5/django/contrib/auth/models.py", line 8, in <module>
from django.db import models
File "/base/data/home/runtimes/python27/python27_lib/versions/third_party/django-1.5/django/db/__init__.py", line 40, in <module>
backend = load_backend(connection.settings_dict['ENGINE'])
File "/base/data/home/runtimes/python27/python27_lib/versions/third_party/django-1.5/django/db/__init__.py", line 34, in __getattr__
return getattr(connections[DEFAULT_DB_ALIAS], item)
File "/base/data/home/runtimes/python27/python27_lib/versions/third_party/django-1.5/django/db/utils.py", line 93, in __getitem__
backend = load_backend(db['ENGINE'])
File "/base/data/home/runtimes/python27/python27_lib/versions/third_party/django-1.5/django/db/utils.py", line 27, in load_backend
return import_module('.base', backend_name)
File "/base/data/home/runtimes/python27/python27_lib/versions/third_party/django-1.5/django/utils/importlib.py", line 35, in import_module
__import__(name)
File "/base/data/home/runtimes/python27/python27_lib/versions/third_party/django-1.5/django/db/backends/mysql/base.py", line 17, in <module>
raise ImproperlyConfigured("Error loading MySQLdb module: %s" % e)
ImproperlyConfigured: Error loading MySQLdb module: No module named MySQLdb

The answer is fairly simple. Add the following lines in the app.yaml file:
libraries:
- name: MySQLdb
version: "latest"
Details can be found on the page
https://cloud.google.com/appengine/docs/python/cloud-sql

Related

Tensorflow Kubernetes Integration Tutorial fails on Ubuntu Xenial

I am following the "Serving Inception Model with TensorFlow Serving and Kubernetes" tutorial from the tensorflow.org website. When I get to loading and exporting the model using
root#ecf82ac60c6b:/serving# bazel-bin/tensorflow_serving/example/inception_saved_model --checkpoint_dir=inception-v3 --output_dir=/tmp/inception-export
I get following error.
Traceback (most recent call last):
File "/serving/bazel-bin/tensorflow_serving/example/inception_saved_model.runfiles/tf_serving/tensorflow_serving/example/inception_saved_model.py", line 202, in <module>
tf.app.run()
File "/serving/bazel-bin/tensorflow_serving/example/inception_saved_model.runfiles/org_tensorflow/tensorflow/python/platform/app.py", line 124, in run
_sys.exit(main(argv))
File "/serving/bazel-bin/tensorflow_serving/example/inception_saved_model.runfiles/tf_serving/tensorflow_serving/example/inception_saved_model.py", line 198, in main
export()
File "/serving/bazel-bin/tensorflow_serving/example/inception_saved_model.runfiles/tf_serving/tensorflow_serving/example/inception_saved_model.py", line 91, in export
table = tf.contrib.lookup.index_to_string_table_from_tensor(class_tensor)
File "/serving/bazel-bin/tensorflow_serving/example/inception_saved_model.runfiles/org_tensorflow/tensorflow/python/util/lazy_loader.py", line 53, in __getattr__
module = self._load()
File "/serving/bazel-bin/tensorflow_serving/example/inception_saved_model.runfiles/org_tensorflow/tensorflow/python/util/lazy_loader.py", line 42, in _load
module = importlib.import_module(self.__name__)
File "/usr/lib/python2.7/importlib/__init__.py", line 37, in import_module
__import__(name)
File "/serving/bazel-bin/tensorflow_serving/example/inception_saved_model.runfiles/org_tensorflow/tensorflow/contrib/__init__.py", line 82, in <module>
from tensorflow.contrib.eager.python import tfe as eager
File "/serving/bazel-bin/tensorflow_serving/example/inception_saved_model.runfiles/org_tensorflow/tensorflow/contrib/eager/python/tfe.py", line 76, in <module>
from tensorflow.contrib.eager.python.datasets import Iterator
File "/serving/bazel-bin/tensorflow_serving/example/inception_saved_model.runfiles/org_tensorflow/tensorflow/contrib/eager/python/datasets.py", line 23, in <module>
from tensorflow.contrib.data.python.ops import prefetching_ops
File "/serving/bazel-bin/tensorflow_serving/example/inception_saved_model.runfiles/org_tensorflow/tensorflow/contrib/data/python/ops/prefetching_ops.py", line 25, in <module>
resource_loader.get_path_to_datafile("../../_prefetching_ops.so"))
File "/serving/bazel-bin/tensorflow_serving/example/inception_saved_model.runfiles/org_tensorflow/tensorflow/contrib/util/loader.py", line 55, in load_op_library
ret = load_library.load_op_library(path)
File "/serving/bazel-bin/tensorflow_serving/example/inception_saved_model.runfiles/org_tensorflow/tensorflow/python/framework/load_library.py", line 56, in load_op_library
lib_handle = py_tf.TF_LoadLibrary(library_filename, status)
File "/serving/bazel-bin/tensorflow_serving/example/inception_saved_model.runfiles/org_tensorflow/tensorflow/python/framework/errors_impl.py", line 473, in __exit__
c_api.TF_GetCode(self.status.status))
tensorflow.python.framework.errors_impl.NotFoundError: /serving/bazel-bin/tensorflow_serving/example/inception_saved_model.runfiles/org_tensorflow/tensorflow/contrib/data/python/ops/../../_prefetching_ops.so: undefined symbol: _ZN6google8protobuf8internal9ArenaImpl10AddCleanupEPvPFvS3_E
I tried the solution on How to troubleshoot deployment of Inception serving running in kubernetes, but it does not apply to this problem. Has anyone encountered the same problem and maybe figured out how to solve it?

AttributeError: 'Settings' object has no attribute 'OSCAR_REQUIRED_ADDRESS_FIELDS'

i have this issue in django oscar when i execute python manage.py migrate i am a beginner in django oscar .any help and suggestions are welcome.
below is my error message.
#localhost production1]$ python manage.py makemigrations
Traceback (most recent call last):
File "manage.py", line 22, in <module>
execute_from_command_line(sys.argv)
File "/usr/lib64/python2.7/site-packages/django/core/management/__init__.py", line 363, in execute_from_command_line
utility.execute()
File "/usr/lib64/python2.7/site-packages/django/core/management/__init__.py", line 337, in execute
django.setup()
File "/usr/lib64/python2.7/site-packages/django/__init__.py", line 27, in setup
apps.populate(settings.INSTALLED_APPS)
File "/usr/lib64/python2.7/site-packages/django/apps/registry.py", line 108, in populate
app_config.import_models()
File "/usr/lib64/python2.7/site-packages/django/apps/config.py", line 202, in import_models
self.models_module = import_module(models_module_name)
File "/usr/lib64/python2.7/importlib/__init__.py", line 37, in import_module
__import__(name)
File "/usr/lib/python2.7/site-packages/oscar/apps/address/models.py", line 1, in <module>
from oscar.apps.address.abstract_models import (
File "/usr/lib/python2.7/site-packages/oscar/apps/address/abstract_models.py", line 19, in <module>
class AbstractAddress(models.Model):
File "/usr/lib/python2.7/site-packages/oscar/apps/address/abstract_models.py", line 35, in AbstractAddress
POSTCODE_REQUIRED = 'postcode' in settings.OSCAR_REQUIRED_ADDRESS_FIELDS
File "/usr/lib64/python2.7/site-packages/django/conf/__init__.py", line 57, in __getattr__
val = getattr(self._wrapped, name)
AttributeError: 'Settings' object has no attribute 'OSCAR_REQUIRED_ADDRESS_FIELDS'
by docs
The last addition to the settings file is to import all of Oscar’s default settings:
from oscar.defaults import *
more details install-by-hand, hope it help you

ImportError: No module named http in odoo

error in odoo 10 when i try to write basic controller for web
from odoo import http
show error
2017-07-09 13:20:10,128 9183 ERROR ? werkzeug: Error on request:
Traceback (most recent call last):
File "/usr/lib/python2.7/dist-packages/werkzeug/serving.py", line 177, in run_wsgi
execute(self.server.app)
File "/usr/lib/python2.7/dist-packages/werkzeug/serving.py", line 165, in execute
application_iter = app(environ, start_response)
File "/odoo/odoo-server/odoo/service/server.py", line 250, in app
return self.app(e, s)
File "/odoo/odoo-server/odoo/service/wsgi_server.py", line 184, in application
return application_unproxied(environ, start_response)
File "/odoo/odoo-server/odoo/service/wsgi_server.py", line 170, in application_unproxied
result = handler(environ, start_response)
File "/odoo/odoo-server/odoo/http.py", line 1307, in __call__
self.load_addons()
File "/odoo/odoo-server/odoo/http.py", line 1328, in load_addons
m = __import__('odoo.addons.' + module)
File "/odoo/odoo-server/odoo/modules/module.py", line 81, in load_module
execfile(modfile, new_mod.__dict__)
File "/odoo/odoo-server/addons/web_printscreen_zb/__init__.py", line 25, in <module>
import controllers
File "/odoo/odoo-server/addons/web_printscreen_zb/controllers.py", line 28, in <module>
import openerp.addons.web.http as openerpweb
File "/odoo/odoo-server/odoo/modules/module.py", line 109, in load_module
mod = importlib.import_module(canonical)
File "/usr/lib/python2.7/importlib/__init__.py", line 37, in import_module
__import__(name)
ImportError: No module named http
i read the documentation of odoo to write web controller but same result.
and
i have tried to
from odoo.addons.web import http
same result
the problem has been solved
by move the code from controller.py to another file file.py
i don't know why this ..!
Try the below
import odoo.http as http

AppRegistryNotReady: Apps aren't loaded yet. Django

I'm trying to run django 1.9 on google app engine. Got the below error when trying to access API's through Google API Explorer.
Traceback (most recent call last):
File "/home/gemini/softwares/google_appengine/google/appengine/runtime/wsgi.py", line 240, in Handle
handler = _config_handle.add_wsgi_middleware(self._LoadHandler())
File "/home/gemini/softwares/google_appengine/google/appengine/runtime/wsgi.py", line 299, in _LoadHandler
handler, path, err = LoadObject(self._handler)
File "/home/gemini/softwares/google_appengine/google/appengine/runtime/wsgi.py", line 96, in LoadObject
__import__(cumulative_path)
File "/home/gemini/projects/cityguide-backend/src/cityguide/api/services.py", line 9, in <module>
from cityguide.api.internal.categories import Categories
File "/home/gemini/projects/cityguide-backend/src/cityguide/api/internal/categories.py", line 10, in <module>
from cityguide.models import Category
File "/home/gemini/projects/cityguide-backend/src/cityguide/models.py", line 8, in <module>
class ContactDetails(models.Model):
File "/home/gemini/projects/cityguide-backend/src/lib/django/db/models/base.py", line 94, in __new__
app_config = apps.get_containing_app_config(module)
File "/home/gemini/projects/cityguide-backend/src/lib/django/apps/registry.py", line 239, in get_containing_app_config
self.check_apps_ready()
File "/home/gemini/projects/cityguide-backend/src/lib/django/apps/registry.py", line 124, in check_apps_ready
raise AppRegistryNotReady("Apps aren't loaded yet.")
AppRegistryNotReady: Apps aren't loaded yet.
I already added
builtins:
- deferred: on
- remote_api: on
- django_wsgi: on
handlers:
- url: .*
script: mysite.wsgi.application
env_variables:
DJANGO_SETTINGS_MODULE: 'mysite.settings'
inside app.yaml file.
wsgi.py looks like
import os
from django.core.wsgi import get_wsgi_application
os.environ.setdefault("DJANGO_SETTINGS_MODULE", "mysite.settings")
application = get_wsgi_application()
I tried adding django.setup() line on the top of models.py but it shows a different error.
ERROR 2016-02-01 10:03:02,918 wsgi.py:263]
Traceback (most recent call last):
File "/home/gemini/softwares/google_appengine/google/appengine/runtime/wsgi.py", line 240, in Handle
handler = _config_handle.add_wsgi_middleware(self._LoadHandler())
File "/home/gemini/softwares/google_appengine/google/appengine/runtime/wsgi.py", line 299, in _LoadHandler
handler, path, err = LoadObject(self._handler)
File "/home/gemini/softwares/google_appengine/google/appengine/runtime/wsgi.py", line 96, in LoadObject
__import__(cumulative_path)
File "/home/gemini/projects/cityguide-backend/src/cityguide/api/services.py", line 9, in <module>
from cityguide.api.internal.categories import Categories
File "/home/gemini/projects/cityguide-backend/src/cityguide/api/internal/categories.py", line 10, in <module>
from cityguide.models import Category
File "/home/gemini/projects/cityguide-backend/src/cityguide/models.py", line 6, in <module>
django.setup()
File "/home/gemini/projects/cityguide-backend/src/lib/django/__init__.py", line 18, in setup
apps.populate(settings.INSTALLED_APPS)
File "/home/gemini/projects/cityguide-backend/src/lib/django/apps/registry.py", line 115, in populate
app_config.ready()
File "/home/gemini/projects/cityguide-backend/src/lib/django/contrib/admin/apps.py", line 22, in ready
self.module.autodiscover()
File "/home/gemini/projects/cityguide-backend/src/lib/django/contrib/admin/__init__.py", line 26, in autodiscover
autodiscover_modules('admin', register_to=site)
File "/home/gemini/projects/cityguide-backend/src/lib/django/utils/module_loading.py", line 50, in autodiscover_modules
import_module('%s.%s' % (app_config.name, module_to_search))
File "/usr/lib/python2.7/importlib/__init__.py", line 37, in import_module
__import__(name)
File "/home/gemini/projects/cityguide-backend/src/cityguide/admin.py", line 2, in <module>
from cityguide.models import Category
ImportError: cannot import name Category
ERROR 2016-02-01 10:03:02,919 wsgi.py:263]
Traceback (most recent call last):
File "/home/gemini/softwares/google_appengine/google/appengine/runtime/wsgi.py", line 240, in Handle
handler = _config_handle.add_wsgi_middleware(self._LoadHandler())
File "/home/gemini/softwares/google_appengine/google/appengine/runtime/wsgi.py", line 299, in _LoadHandler
handler, path, err = LoadObject(self._handler)
File "/home/gemini/softwares/google_appengine/google/appengine/runtime/wsgi.py", line 96, in LoadObject
__import__(cumulative_path)
File "/home/gemini/projects/cityguide-backend/src/cityguide/api/services.py", line 9, in <module>
from cityguide.api.internal.categories import Categories
File "/home/gemini/projects/cityguide-backend/src/cityguide/api/internal/categories.py", line 10, in <module>
INFO 2016-02-01 10:03:03,000 module.py:794] default: "POST /_ah/spi/BackendService.getApiConfigs HTTP/1.1" 500 -
from cityguide.models import Category
INFO 2016-02-01 10:03:03,001 module.py:794] default: "POST /_ah/spi/BackendService.getApiConfigs HTTP/1.1" 500 -
File "/home/gemini/projects/cityguide-backend/src/cityguide/models.py", line 6, in <module>
INFO 2016-02-01 10:03:03,001 module.py:794] default: "GET /_ah/api/discovery/v1/apis HTTP/1.1" 500 60
django.setup()
INFO 2016-02-01 10:03:03,001 module.py:794] default: "GET /_ah/api/discovery/v1/apis HTTP/1.1" 500 60
File "/home/gemini/projects/cityguide-backend/src/lib/django/__init__.py", line 18, in setup
apps.populate(settings.INSTALLED_APPS)
File "/home/gemini/projects/cityguide-backend/src/lib/django/apps/registry.py", line 78, in populate
raise RuntimeError("populate() isn't reentrant")
RuntimeError: populate() isn't reentrant
Temporary solution for this problem:
Seems like I need to open the home page first. So that it would loads the db since I made the homepage to return all the db table contents . Once the db lists shown on the home page, we are ready to call the Google API Explorer.
Is there any way to refine this solution?
You should first initiate django this way in your script:
import django
django.setup()
See https://docs.djangoproject.com/en/1.9/ref/applications/#django.setup
You can also look at the Troubleshooting section of the link to see other possibilities to solve this aprticular exception.
By adding the above two lines at the top of services.py file solves this problem for me..
In your script initiate django as:
from django_root_app.wsgi import application

Django migration

I have migrated django website from live server to my localhost, i took the backup of posrgresql database and attached to my localhost i have changed the databse connection details in the live_setting.py and also installed the required packages which were already installed on the live server but i am unable to run the website on my localhost when i use manage.py ruserver command i got the following errors.
Unhandled exception in thread started by <bound method Command.inner_run of <django.contrib.staticfiles.management.commands.runserver.Command object at 0x02BB6530>>
Traceback (most recent call last):
File "C:\Python26\lib\site-packages\django\core\management\commands\runserver.py", line 91, in inner_run self.validate(display_num_errors=True)
File "C:\Python26\lib\site-packages\django\core\management\base.py", line 266,in validate num_errors = get_validation_errors(s, app)
File "C:\Python26\lib\site-packages\django\core\management\validation.py", line 30, in get_validation_errors for (app_name, error) in get_app_errors().items():
File "C:\Python26\lib\site-packages\django\db\models\loading.py", line 158, inget_app_errors self._populate()
File "C:\Python26\lib\site-packages\django\db\models\loading.py", line 67, in_populate self.load_app(app_name)
File "C:\Python26\lib\site-packages\django\db\models\loading.py", line 88, in load_app models = import_module('.models', app_name)
File "C:\Python26\lib\site-packages\django\utils\importlib.py", line 35, in import_module__import__(name)
File "C:\Python26\lib\site-packages\django_social_auth3-0.7.20-py2.6.egg\social_auth\models.py", line 8, in <module>'social_auth.db.django_models'))
File "C:\Python26\lib\site-packages\django\utils\importlib.py", line 35, in import_module__import__(name)
File "C:\Python26\lib\site-packages\django_social_auth3-0.7.20-py2.6.egg\social_auth\db\django_models.py", line 5, in <module>from social_auth.db.base import UserSocialAuthMixin, AssociationMixin, \
File "C:\Python26\lib\site-packages\django_social_auth3-0.7.20-py2.6.egg\social_auth\db\base.py", line 7, in <module> from openid.association import Association as OIDAssociation
File "build\bdist.win32\egg\openid\association.py", line 37, in <module>
File "build\bdist.win32\egg\openid\cryptutil.py", line 33, in <module>
File "build\bdist.win32\egg\openid\oidutil.py", line 16, in <module> ImportError: No module named parse
I am using python 2.6 and django 1.4.3, how can i solve these errors, i am new to python/django development.

Categories

Resources