Zappa: when slim_handler is used MySQLdb cannot be found by Django
this issue is similar to #755 when using the zappa_settings.json configuration to turn on “use_precompiled_packages”:true and then turning on “slim_handler”: true I get error below:
1491418915817] Error loading MySQLdb module: libmysqlclient.so.18: cannot open shared object file: No such file or directory: ImproperlyConfigured Traceback (most recent call last): File "/var/task/handler.py", line 508, in lambda_handler return LambdaHandler.lambda_handler(event, context) File "/var/task/handler.py", line 239, in lambda_handler handler = cls() File "/var/task/handler.py", line 142, in __init__ wsgi_app_function = get_django_wsgi(self.settings.DJANGO_SETTINGS) File "/var/task/django_zappa_app.py", line 20, in get_django_wsgi return get_wsgi_application() File "/private/var/folders/7c/lt6hvzr97z919lwy5yxyfs7w0000gn/T/pip-build-YiIZfn/django/django/core/wsgi.py", line 14, in get_wsgi_application File "/tmp/dailyfantasyser/django/__init__.py", line 18, in setup apps.populate(settings.INSTALLED_APPS) File "/tmp/dailyfantasyser/django/apps/registry.py", line 108, in populate app_config.import_models(all_models) File "/tmp/dailyfantasyser/django/apps/config.py", line 198, 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 "/private/var/folders/7c/lt6hvzr97z919lwy5yxyfs7w0000gn/T/pip-build-YiIZfn/django/django/contrib/auth/models.py", line 41, in <module> File "/private/var/folders/7c/lt6hvzr97z919lwy5yxyfs7w0000gn/T/pip-build-YiIZfn/django/django/db/models/base.py", line 139, in __new__ File "/private/var/folders/7c/lt6hvzr97z919lwy5yxyfs7w0000gn/T/pip-build-YiIZfn/django/django/db/models/base.py", line 324, in add_to_class File "/private/var/folders/7c/lt6hvzr97z919lwy5yxyfs7w0000gn/T/pip-build-YiIZfn/django/django/db/models/options.py", line 250, in contribute_to_class File "/private/var/folders/7c/lt6hvzr97z919lwy5yxyfs7w0000gn/T/pip-build-YiIZfn/django/django/db/__init__.py", line 36, in __getattr__ File "/private/var/folders/7c/lt6hvzr97z919lwy5yxyfs7w0000gn/T/pip-build-YiIZfn/django/django/db/utils.py", line 240, in __getitem__ File "/private/var/folders/7c/lt6hvzr97z919lwy5yxyfs7w0000gn/T/pip-build-YiIZfn/django/django/db/utils.py", line 111, in load_backend File "/usr/lib64/python2.7/importlib/__init__.py", line 37, in import_module __import__(name) File "/private/var/folders/7c/lt6hvzr97z919lwy5yxyfs7w0000gn/T/pip-build-YiIZfn/django/django/db/backends/mysql/base.py", line 27, in <module> ImproperlyConfigured: Error loading MySQLdb module: libmysqlclient.so.18: cannot open shared object file: No such file or directory
I am running in virtualenv on macos10.12.3 with python2.7, Django 1.8.5.
Expected Behavior
the error should not occur and the library should be found in the proper location for Django to run properly.
Actual Behavior
the following error: ImproperlyConfigured: Error loading MySQLdb module: libmysqlclient.so.18: cannot open shared object file: No such file or directory
Possible Fix
Steps to Reproduce
- update project to use_precompiled_packages:true and slim_handler:true
- deploy large project using zappa update staging
- run zappa tail to view the log
Your Environment
- Zappa version used: 0.40.0p
- Operating System and Python version: macos10.12.3
- Link to your project (optional):
- Your
zappa_settings.py:
{ "staging": { "aws_region": "us-east-1", "django_settings": "daily.settings_lambda", "s3_bucket": "daily", "memory_size": 1024, "timeout_seconds": 120, "use_precompiled_packages": true, "slim_handler": true, "delete_local_zip": false, "log_level": "DEBUG", } }
About this issue
- Original URL
- State: closed
- Created 7 years ago
- Comments: 24 (8 by maintainers)
Commits related to this issue
- #776 fix for libmysqlclient.so.18 error Added include to zappa_settings Added ctypes to handler to load the selected libraries directly to PYTHONPATH — committed to timj98/Zappa by timj98 7 years ago
- Merge pull request #789 from timj98/master #776 fix for libmysqlclient.so.18 error when using slim_handler — committed to Miserlou/Zappa by deleted user 7 years ago
I also still have issues. When I add include:[] it does not work and the code still tries to import libmysqlclient.so.18
“include”: [] in the Zappa_settings.json file didn’t work for me either.
adding include : [] does not help. How can I add postgres to include?
@timj98 let me tell you my fix. I had to mention include=[] in my zappa settings. Which will be non-obvious to many, if they don’t follow the code. I let you or @miserlou to decide on this one.
I am now having this problem as well. I have an existing Django 3/Zappa 0.51/Postgres 10 project that works fine. I created a new project, copying the old project’s zappa_settings.json and tweaking values as appropriate, but it can’t deploy at all. I’m now concerned that this problem will crop up on my old project at some point, which is an issue since it’s a production critical environment. I have never had an include or exclude in my zappa_settings.json and adding one to the new project doesn’t seem to help.