Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Django on AWS Elastic Beanstalk - No module named MySQLdb Error

I have been using AWS Elastic Beanstalk to run this web app for a while with no issues on Amazon's Linux version Python 2.7 running on 64bit Amazon Linux/2.0.1.

When I tried to "upgrade" to the latest Amazon Linux version: Python 2.7 version, Linux/2.7.7 or any version after 2.0.1, I get this error:

ImproperlyConfigured: Error loading MySQLdb module: No module named MySQLdb.

Did you install mysqlclient or MySQL-python?

I do have both installed and included in my requirements.txt file

MySQL-python==1.2.5
mysqlclient==1.3.14

I tried reinstalling them both and removing them one or the other from the requirements but still no luck.

in my .ebextensions I do have these:

packages:
    yum:
        python27-devel: []
        libmemcached-devel: []
        gcc: []
        libxml2-devel: []
        libxslt-devel: []

I have added the gcc and libx after that so I know they are not causing the error. (I did not try to remove the python27-devel or the libmemcached-devel

Any ideas?

What has changed beyond 2.0.1 since everything is working correctly running version 2.0.1 and it is not working on any newer EB version?

like image 312
WayBehind Avatar asked Dec 23 '18 02:12

WayBehind


2 Answers

From looking through some past work, I think you may need to add mysql-devel to the yum section in your .ebextensions file

like image 115
Esteban Avatar answered Sep 21 '22 00:09

Esteban


This happened to me as well, from what I can remember is you might need to rebuild the virtual env. In the elastic beanstalk console. Or using the eb command line interface.

like image 34
Kareem Avatar answered Sep 19 '22 00:09

Kareem