2

I'm trying to connect my Django Elastic Beanstalk to my RDS MySQL. My Django works with my RDS MySQL through localhost, but when trying to upload my Django to Elastic Beanstalk I get "failed to deploy application" and AWS shows errors (below). My project has mysqlclient in requirements.txt, like here:

https://docs.aws.amazon.com/elasticbeanstalk/latest/dg/create-deploy-python-rds.html

According to that page, that should be enough. I've of course tried to search for similar questions but haven't had success so far. I've noticed that many questions refer to needing a packages.config file inside .ebextensions, I tried many of those suggestions without success. Is that the problem? Why wouldn't that be mentioned on the AWS page?

  × python setup.py egg_info did not run successfully.
  │ exit code: 1
  ╰─> [16 lines of output]
      /bin/sh: mysql_config: command not found
      /bin/sh: mariadb_config: command not found
      /bin/sh: mysql_config: command not found
      Traceback (most recent call last):
        File "<string>", line 2, in <module>
        File "<pip-setuptools-caller>", line 34, in <module>
        File "/tmp/pip-install-r0dz9d2g/mysqlclient_f2b5c53e43a648c284b06f7af63d9855/setup.py", line 15, in <module>
          metadata, options = get_config()
        File "/tmp/pip-install-r0dz9d2g/mysqlclient_f2b5c53e43a648c284b06f7af63d9855/setup_posix.py", line 70, in get_config
          libs = mysql_config("libs")
        File "/tmp/pip-install-r0dz9d2g/mysqlclient_f2b5c53e43a648c284b06f7af63d9855/setup_posix.py", line 31, in mysql_config
          raise OSError("{} not found".format(_mysql_config_path))
      OSError: mysql_config not found
      mysql_config --version
      mariadb_config --version
      mysql_config --libs
      [end of output]
phershbe
  • 169
  • 4
  • 12
  • fyi this was updated [here](https://stackoverflow.com/questions/76197174/aws-elastic-beanstalk-cant-install-mysqlclient) with a new package requirement – Aaron Melgar Jun 14 '23 at 02:50

1 Answers1

0

Answering my own question. I asked something similar later AWS Elastic Beanstalk RDS MacOS mysqlclient not working and got help.

The answer was indeed the packages.config file with yum installing the necessary files (check the link above). There was something off somewhere else in my code but the errors that I got were the same as above, even though packages.config was setup properly. I figured it out because I tried to set it back to the SQLite database and upload it to Elastic Beanstalk and it didn't work. (I don't remember what errors I got sorry, I was stressed out, I think the "111: Connection refused" errors again though.)

The way I got things working was to delete all of my configuration files and start again from the regular finished project and then follow the tutorials (like I was doing before): https://docs.aws.amazon.com/elasticbeanstalk/latest/dg/create-deploy-python-django.html https://docs.aws.amazon.com/elasticbeanstalk/latest/dg/create-deploy-python-rds.html#python-rds-connect

From there, I added a packages.config file inside my .ebextensions folder with the following code...

packages: 
  yum:
    python3-devel: []
    mariadb-devel: []

...as is noted in my other question linked to above as well as here: mysqlclient installation error in AWS Elastic Beanstalk

I also needed gunicorn and a Procfile, I had that problem solved before anyway but it's worth mentioning in case you're here because of problems with Elastic Beanstalk and RDS.

I also didn't understand if I could use yum in the packages.config file if I didn't have it on my computer, especially since I use MacOS and it's not common to use yum on MacOS. That question was answered in my other question linked to at the top of this answer, the answer being that you do not need yum on your computer in this case, because yum is being used in this case by the Amazon Linux 2 server from Elastic Beanstalk.

phershbe
  • 169
  • 4
  • 12