0

I am trying to deploy my django project on Elastic Beanstalk. I am following the official document and this article and I think I have done most of the things asked in those resources correctly.

But my deployment is failing every time. On eb logs I found this error

  No matching distribution found for pkg-resources==0.0.0 (from -r /opt/python/ondeck/app/requirements.txt (line 27))
  You are using pip version 9.0.1, however version 20.1.1 is available.
  You should consider upgrading via the 'pip install --upgrade pip' command.
  2020-07-07 18:19:51,388 ERROR    Error installing dependencies: Command '/opt/python/run/venv/bin/pip install -r /opt/python/ondeck/app/requirements.txt' returned non-zero exit status 1
  Traceback (most recent call last):
    File "/opt/elasticbeanstalk/hooks/appdeploy/pre/03deploy.py", line 22, in main
      install_dependencies()
    File "/opt/elasticbeanstalk/hooks/appdeploy/pre/03deploy.py", line 18, in install_dependencies
      check_call('%s install -r %s' % (os.path.join(APP_VIRTUAL_ENV, 'bin', 'pip'), requirements_file), shell=True)
    File "/usr/lib64/python2.7/subprocess.py", line 190, in check_call
      raise CalledProcessError(retcode, cmd)
  CalledProcessError: Command '/opt/python/run/venv/bin/pip install -r /opt/python/ondeck/app/requirements.txt' returned non-zero exit status 1 (Executor::NonZeroExitStatus)

So far my problem seems very similar to this stackoverflow question but it is not. I removed the pkg-resources==0.0.0 from requirements.txt but it is still giving me the same error.

My requirements.txt

asgiref==3.2.10
attrs==19.3.0
awsebcli==3.18.1
bcrypt==3.1.7
blessed==1.17.8
botocore==1.15.49
cached-property==1.5.1
cement==2.8.2
certifi==2020.6.20
cffi==1.14.0
chardet==3.0.4
colorama==0.4.3
cryptography==2.9.2
Django==3.0.8
django-cors-headers==3.3.0
djangorestframework==3.11.0
djangorestframework-simplejwt==4.4.0
docker==4.2.2
docker-compose==1.25.5
dockerpty==0.4.1
docopt==0.6.2
docutils==0.15.2
future==0.16.0
idna==2.7
importlib-metadata==1.7.0
jmespath==0.10.0
jsonschema==3.2.0
paramiko==2.7.1
pathspec==0.5.9
psycopg2-binary==2.8.5
pycparser==2.20
PyJWT==1.7.1
PyNaCl==1.4.0
pyrsistent==0.16.0
python-dateutil==2.8.0
pytz==2020.1
PyYAML==5.3.1
requests==2.20.1
semantic-version==2.5.0
six==1.11.0
sqlparse==0.3.1
termcolor==1.1.0
texttable==1.6.2
urllib3==1.24.3
wcwidth==0.1.9
websocket-client==0.57.0
zipp==3.1.0

I have tried to launch new application and new environment for like 5 times now and nothing changed.

Marcin
  • 215,873
  • 14
  • 235
  • 294
f1uk3r
  • 317
  • 7
  • 15
  • Seems you are running Amazon Linux 1. I run your `requirements.txt` on EB with AL2, and had no issue. Do you specifically want to use AL1? – Marcin Jul 08 '20 at 00:19
  • I do not, but I thought since I am working on python 3.6.9 locally, I should use AL1 with 3.6. They only have AL2 for python 3.7 I guess. – f1uk3r Jul 08 '20 at 05:23
  • Yes. Can you login to the EB instance of yours, and run the pip command (or install the entire app) manually? This will tell us if the issue occurs only during automated deployment, or also when done manually. – Marcin Jul 08 '20 at 05:27
  • How do i run pip command in EB instance? – f1uk3r Jul 08 '20 at 06:25
  • The error msg indicates: `/opt/python/run/venv/bin/pip install -r /opt/python/ondeck/app/requirements.txt` Maybe change the `requirements.txt` to where the file is when you run it manually – Marcin Jul 08 '20 at 06:27
  • I have changed my requirements.txt locally to remove `pkg-resources==0.0.0`. I don't know where is this path `/opt/python/ondeck/app/requirements.txt`. Where can I find this path exactly? – f1uk3r Jul 08 '20 at 07:02
  • I'm not sure. That's what your error message says. It should be on your EB instance. – Marcin Jul 08 '20 at 07:12
  • There is other command as well `/opt/python/run/venv/bin/pip install -r /opt/python/ondeck/app/requirements.txt' `. If not, then just try `pip install -r requirements.txt` with the path to your requirements.txt. – Marcin Jul 08 '20 at 07:15

1 Answers1

0

I was seeing a very similar thing to you.

I was made a change in the requirement files to remove pkg-resources==0.0.0, however when running eb logs, it said it was still failing for this reason when I ran eb deploy.

However, when I checked the timestamp in eb logs, the timestamp was before I ran eb deploy. I think here you are being shown a failure for a previous deployment.

To check, run eb ssh to get into your server, and look in /var/log/eb-engine.log and the latest log should be information as to why the commands are actually failing (if you are following that tutorial, probably because pg_config isn't found).

You can also verify this is your issue by running /opt/python/run/venv/bin/pip install -r /opt/python/ondeck/app/requirements.txt on the server as the comments suggest, and see if you still hit the same error.

If your file /opt/python/ondeck/app/requirements.txt doesn't contain pkg-resources and it still fails for that reason locally, then I'm afraid I don't know what's going on!

semaj
  • 21
  • 2
  • 1