aws / elastic-beanstalk-roadmap

AWS Elastic Beanstalk roadmap
https://aws.amazon.com/elasticbeanstalk/
Creative Commons Attribution Share Alike 4.0 International
283 stars 11 forks source link

Django Application is failing at mysqlclient while deploying #161

Open yaswanthmangalagiri opened 3 years ago

yaswanthmangalagiri commented 3 years ago

Hi, I was trying to deploy my Django application on Elastic bean and the requirement.txt file contents are as follows

Django==3.1.2
boto3==1.16.5
botocore==1.19.5
gunicorn==20.0.4
django-storages
mysqlclient==2.0.1
psycopg2-binary==2.8.6
whitenoise

when I ran eb deploy from my local the mysqlclient installation is failing with the below error.

Collecting mysqlclient==2.0.3
  Using cached mysqlclient-2.0.3.tar.gz (88 kB)

2021/04/08 14:21:02.972795 [ERROR] An error occurred during execution of command [app-deploy] - [InstallDependency]. Stop running the command. Error: fail to install dependencies with requirements.txt file with error Command /bin/sh -c /var/app/venv/staging-LQM1lest/bin/pip install -r requirements.txt failed with error exit status 1. Stderr:    ERROR: Command errored out with exit status 1:
     command: /var/app/venv/staging-LQM1lest/bin/python -c 'import sys, setuptools, tokenize; sys.argv[0] = '"'"'/tmp/pip-install-tjq5n50q/mysqlclient_4e6d9c406c334c31a0dedbbd674f919b/setup.py'"'"'; __file__='"'"'/tmp/pip-install-tjq5n50q/mysqlclient_4e6d9c406c334c31a0dedbbd674f919b/setup.py'"'"';f=getattr(tokenize, '"'"'open'"'"', open)(__file__);code=f.read().replace('"'"'\r\n'"'"', '"'"'\n'"'"');f.close();exec(compile(code, __file__, '"'"'exec'"'"'))' egg_info --egg-base /tmp/pip-pip-egg-info-z80lf9t8
         cwd: /tmp/pip-install-tjq5n50q/mysqlclient_4e6d9c406c334c31a0dedbbd674f919b/
    Complete output (15 lines):
    /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 1, in <module>
      File "/tmp/pip-install-tjq5n50q/mysqlclient_4e6d9c406c334c31a0dedbbd674f919b/setup.py", line 15, in <module>
        metadata, options = get_config()
      File "/tmp/pip-install-tjq5n50q/mysqlclient_4e6d9c406c334c31a0dedbbd674f919b/setup_posix.py", line 70, in get_config
        libs = mysql_config("libs")
      File "/tmp/pip-install-tjq5n50q/mysqlclient_4e6d9c406c334c31a0dedbbd674f919b/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
    ----------------------------------------
WARNING: Discarding https://files.pythonhosted.org/packages/3c/df/59cd2fa5e48d0804d213bdcb1acb4d08c403b61c7ff7ed4dd4a6a2deb3f7/mysqlclient-2.0.3.tar.gz#sha256=f6ebea7c008f155baeefe16c56cd3ee6239f7a5a9ae42396c2f1860f08a7c432 (from https://pypi.org/simple/mysqlclient/) (requires-python:>=3.5). Command errored out with exit status 1: python setup.py egg_info Check the logs for full command output.
ERROR: Could not find a version that satisfies the requirement mysqlclient==2.0.3
ERROR: No matching distribution found for mysqlclient==2.0.3

I deployed the same app on Heroku it worked fine ran the app without errors.

januszm commented 3 years ago

Amazon Linux 2 comes with mariadb-devel preinstalled afaik. eb ssh and try rpm -qa | grep -E '(mariadb|mysql)'

packages:
  yum:
    mariadb-devel: []

to .ebextensions if you're missing this package

saranshsingh1 commented 3 years ago

@yaswanthmangalagiri Try updating the requirements.txt file to use mysqlclient==2.0.3. The dependency in the file and the version for mysqlclient in the error don't match for some reason.

MSBPeace commented 3 years ago

@saranshsingh1 I think there is something else at play here:

WARNING: Discarding https://files.pythonhosted.org/packages/3c/df/59cd2fa5e48d0804d213bdcb1acb4d08c403b61c7ff7ed4dd4a6a2deb3f7/mysqlclient-2.0.3.tar.gz#sha256=f6ebea7c008f155baeefe16c56cd3ee6239f7a5a9ae42396c2f1860f08a7c432 (from https://pypi.org/simple/mysqlclient/) (requires-python:>=3.5). Command errored out with exit status 1: python setup.py egg_info Check the logs for full command output.
ERROR: Could not find a version that satisfies the requirement mysqlclient==2.0.3 (from versions: 1.3.0, 1.3.1, 1.3.2, 1.3.3, 1.3.4, 1.3.5, 1.3.6, 1.3.7, 1.3.8, 1.3.9, 1.3.10, 1.3.11rc1, 1.3.11, 1.3.12, 1.3.13, 1.3.14, 1.4.0rc1, 1.4.0rc2, 1.4.0rc3, 1.4.0, 1.4.1, 1.4.2, 1.4.2.post1, 1.4.3, 1.4.4, 1.4.5, 1.4.6, 2.0.0, 2.0.1, 2.0.2, 2.0.3)
ERROR: No matching distribution found for mysqlclient==2.0.3

Suggests that the 2.0.3 version that is available has been discarded because the requirement: python >= 3.5 hasn't been satisfied. This suggests that not even python is being loaded correctly.