question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

Django mysqlclient issue with using Python 3.7.2

See original GitHub issue

Context

I am trying to deploy a django app using mysql. However, an issue arises.

Using sqlite works fine. But, using mysql causes an error that fails to load MySQLdb.

There is nothing wrong with python3.6

An issue occurs in python3.7.

Actual Behavior

get a 502 error from Zappa API

Error: Warning! Status check on the deployed lambda failed. A GET request to '/' yielded a 502 response code.

The ‘zappa tail’ looks like this:

[1553164824234] [ERROR] ImproperlyConfigured: Error loading MySQLdb module.     ) from errask/django/db/backends/mysql/base.py", line 20, in <module>rt_module

Possible Fix

Support for python3.7 in lambda-packages(mysqlclient, etc…)

Steps to Reproduce

  1. Deploy Zappa app with using mysqlclient

Your Environment

  • Zappa version used: 0.48.2
  • Operating System and Python version: mac and 3.7.2
  • The output of pip freeze: argcomplete==1.9.3 boto3==1.9.118 botocore==1.12.118 certifi==2019.3.9 cfn-flip==1.1.0.post1 chardet==3.0.4 Click==7.0 Django==2.1.7 django-cors-headers==2.5.2 django-storages==1.7.1 djangorestframework==3.9.2 djangorestframework-stubs==0.3.0 docutils==0.14 durationpy==0.5 future==0.16.0 hjson==3.0.1 idna==2.8 jmespath==0.9.3 kappa==0.6.0 lambda-packages==0.20.0 mysqlclient==1.3.12 placebo==0.9.0 python-dateutil==2.6.1 python-decouple==3.1 python-slugify==1.2.4 pytz==2018.9 PyYAML==5.1 requests==2.21.0 s3transfer==0.2.0 six==1.12.0 toml==0.10.0 tqdm==4.19.1 troposphere==2.4.5 Unidecode==1.0.23 urllib3==1.24.1 Werkzeug==0.15.0 wsgi-request-logger==0.4.6 zappa==0.48.2
  • Your zappa_settings.py: { “prod”: { “aws_region”: “ap-northeast-2”, “django_settings”: “LcBot.settings”, “profile_name”: “default”, “project_name”: “lc-bot”, “runtime”: “python3.7”, “s3_bucket”: “lc-bot” } }

Issue Analytics

  • State:open
  • Created 5 years ago
  • Reactions:9
  • Comments:15 (1 by maintainers)

github_iconTop GitHub Comments

13reactions
shpyrcommented, Jan 14, 2020

@Kelvin97lui it’s pretty easy to get around that, here’s what I ended up doing:

import pymysql
pymysql.install_as_MySQLdb()
pymysql.version_info = (1, 3, 13, 'final', 0)

^ this is at the top of my settings.py.

12reactions
ge0rgcommented, Jan 14, 2020

You can work around the lack of native binaries by using pymysql instead of mysqlclient as described in this SO post:

pip install pymysql

And add to your project’s __init__.py:

import pymysql
pymysql.install_as_MySQLdb()

This will add about 6MB to your ZIP size.

Read more comments on GitHub >

github_iconTop Results From Across the Web

Fresh python 3.7 / django 2.2.1 installation not recognising ...
Any ideas why django can't see the mysqlclient installed in the virtualenv? I can confirm that all of the above has been run...
Read more >
How to fix the 'pip install mysqlclient' error in Python
How to fix the 'pip install mysqlclient' error in Python ... Note: You can follow this link to learn how to successfully start...
Read more >
mysqlclient installation error - Google Groups
While installing mysqlclient using pip, getting this error ... Python : 3.7. Django : ... MySQL client is not available for Django 2.2...
Read more >
Error Failed building wheel for MySql-Python - Edureka
I am new to python and I am trying django framework that involves some MySql and ran into this error when try to...
Read more >
[Solved] pip install mysqlclient error - YouTube
Django in Hindi. [Solved] pip install mysqlclient error | How to install python mysqlclient. 12K views 2 years ago. Pankaj Panjwani.
Read more >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found