Troubleshooting Deploying a Django Application With Elastic Beanstalk: Difference between revisions

From Littledamien Wiki
Jump to navigation Jump to search
No edit summary
No edit summary
Line 3: Line 3:


An ongoing list of issues, with solutions as they are found, that I have encountered while deploying a Django web application using Elastic Beanstalk.
An ongoing list of issues, with solutions as they are found, that I have encountered while deploying a Django web application using Elastic Beanstalk.
== Errors installing `awsebcli` on Mac OS for Python 2.7 ==
'''Use case'''
<syntaxhighlight lang="bash">
$pip install awsebcli
</syntaxhighlight>
<syntaxhighlight lang="text">
[...]
Exception:
Traceback (most recent call last):
  File "/Library/Python/2.7/site-packages/pip/basecommand.py", line 209, in main
    status = self.run(options, args)
[...]
</syntaxhighlight>
'''Cause'''
OS X El Capitan ships with `six` 1.4.1 already installed. `awscli` < `botocore` < `python-dateutil` < `six>=1.5`. pip doesn't have permission to System Integrity Protection doesn't it to modify directories.<ref>[https://github.com/pypa/pip/issues/3165 Six issue when installing package] - pypa / pip GitHub Issues</ref>
In addition, I suspect I may have installed some components using `sudo pip`. I realize now that it's pretty much always inappropriate to use `sudo` with `pip`.
''' Fix'''
''(Using `sudo` in cases like this may be bad practice, but at this point it was the only way to get it to work with Python 2.7.)''<ref>[http://stackoverflow.com/a/33136494/1399562 “OSError: [Errno 1] Operation not permitted” when installing Scrapy in OSX 10.11 (El Capitan) (System Integrity Protection)] - Stack Overflow</ref>
<syntaxhighlight lang="bash">
$ sudo pip install --ignore-installed awsebcli
</syntaxhighlight>


== "No environment found" error with aws eb cli ==
== "No environment found" error with aws eb cli ==
Line 62: Line 93:


It's necessary to `ssh` to the correct EC2 instance to run `eb deploy`. Go back to the AWS EC2 console, find the EC2 instance corresponding to the new EB environment, and `ssh` to its public DNS.
It's necessary to `ssh` to the correct EC2 instance to run `eb deploy`. Go back to the AWS EC2 console, find the EC2 instance corresponding to the new EB environment, and `ssh` to its public DNS.
== Notes ==
<references />

Revision as of 23:05, 9 February 2016

Overview

An ongoing list of issues, with solutions as they are found, that I have encountered while deploying a Django web application using Elastic Beanstalk.

Errors installing awsebcli on Mac OS for Python 2.7

Use case

$pip install awsebcli
[...]
Exception:
Traceback (most recent call last):
  File "/Library/Python/2.7/site-packages/pip/basecommand.py", line 209, in main
    status = self.run(options, args)
[...]

Cause

OS X El Capitan ships with six 1.4.1 already installed. awscli < botocore < python-dateutil < six>=1.5. pip doesn't have permission to System Integrity Protection doesn't it to modify directories.[1]

In addition, I suspect I may have installed some components using sudo pip. I realize now that it's pretty much always inappropriate to use sudo with pip.

Fix

(Using sudo in cases like this may be bad practice, but at this point it was the only way to get it to work with Python 2.7.)[2]

$ sudo pip install --ignore-installed awsebcli

"No environment found" error with aws eb cli

Use case

Almost all eb commands result in an error the effect of No Environment found for EnvironmentName = 'name-ev'.

Cause

An EB environment was created, but then not deleted entirely.

Fix

Delete the environment through the AWS console, and then delete the .elasticbeanstalk/ and .ebextensions/ directories.

Zip file errors while installing a custom Django module

Use case

pip install path/to/my-custom-package.0.1.zip results in error: BadZipFile: File is not a zip file.

Cause

This happened after using wget to retrieve a .zip archive off GitHub.

Despite the .zip extension, the file type can register as HTML on Linux.

Fix

Test the file type:

$ file myzipfile.zip
myzipfile.zip: HTML document, UTF-8 Unicode txt, with very long lines

Upload the zip file to the server using scp:

`scp -i path/to/namekey_pair.pem path/to/source.zip ec2-user@public_dns.us-west-2.compute.amazonaws.com:path/to/dest.zip`

(Where namekey_pair.pem is the actual name of a .pem file, and public_dns is the actual address of the public dns from the EC2 console.)

eb deploy errors where EB environment doesn't match

Use case

Attempting to update .ebextensions/01-packages.config to list Git and PostgreSQL as packages to install, then running eb deploy to install the packages, the deploy process quits with errors to the effect that the YAML is malformed in the .config file. Editing the file makes it evident that the errors are originating in another environment.

Cause

Logged into wrong EC2 instance.

You can log into an EC2 instance and run eb init and eb create commands to create new Elastic Beanstalk applications and environments. The new app will spawn a new EC2 instance, that is separate from the current EC2 instance.

Fix

It's necessary to ssh to the correct EC2 instance to run eb deploy. Go back to the AWS EC2 console, find the EC2 instance corresponding to the new EB environment, and ssh to its public DNS.

Notes

  1. Six issue when installing package - pypa / pip GitHub Issues
  2. “OSError: [Errno 1 Operation not permitted” when installing Scrapy in OSX 10.11 (El Capitan) (System Integrity Protection)] - Stack Overflow