Deploying a Django app on AWS: Difference between revisions

From Littledamien Wiki
Jump to navigation Jump to search
No edit summary
Line 26: Line 26:
</syntaxhighlight>
</syntaxhighlight>


=== Install `virtualenv` ===
=== Create a virtual Python environment for the EC2 instance ===
 
Install `virtualenv` if needed:


<syntaxhighlight lang="bash">
<syntaxhighlight lang="bash">
$ which virtualenv
$ pip install virtualenv
$ pip install virtualenv
</syntaxhighlight>
Create the virtual Python Environment<ref>[http://docs.aws.amazon.com/elasticbeanstalk/latest/dg/create-deploy-python-common-steps.html#python-common-setup-venv Setting up a virtual Python environment] (AWS documentation)</ref>
<syntaxhighlight lang="bash">
$ virtualenv -p python3.4 /tmp/py34_nrose_env
</syntaxhighlight>
Where `py34_nrose_env` is a name that makes sense for the app's virtual environment.
Start the virtual environment:
<syntaxhighlight lang="bash">
$ . /tmp/eb_python_app/bin/activate
</syntaxhighlight>
Confirm the Python version:
<syntaxhighlight lang="bash">
$ python --version
</syntaxhighlight>
</syntaxhighlight>



Revision as of 17:23, 6 February 2016

Prerequisites

Install Python

Check for python and pip, and their versions:

$ python --verison
$ pip --version

Python 3.x

Python 3.x is often invoked as python3.

$ python3 --verison

If Python 3 is not installed:[1]

$ sudo yum list | grep python3
$ sudo yum install python34 # or relevant version

Create a virtual Python environment for the EC2 instance

Install virtualenv if needed:

$ which virtualenv
$ pip install virtualenv

Create the virtual Python Environment[2]

$ virtualenv -p python3.4 /tmp/py34_nrose_env

Where py34_nrose_env is a name that makes sense for the app's virtual environment.

Start the virtual environment:

$ . /tmp/eb_python_app/bin/activate

Confirm the Python version:

$ python --version

Notes

See also

References