- Python Basic Tutorial
- Python - Home
- Python - Overview
- Python - Environment Setup
- Python - Basic Syntax
- Python - Comments
- Python - Variables
- Python - Data Types
- Python - Operators
- Python - Decision Making
- Python - Loops
- Python - Numbers
- Python - Strings
- Python - Lists
- Python - Tuples
- Python - Dictionary
- Python - Date & Time
- Python - Functions
- Python - Modules
- Python - Files I/O
- Python - Exceptions
- Python Advanced Tutorial
- Python - Classes/Objects
- Python - Reg Expressions
- Python - CGI Programming
- Python - Database Access
- Python - Networking
- Python - Sending Email
- Python - Multithreading
- Python - XML Processing
- Python - GUI Programming
- Python - Further Extensions
How to set up your python development environment on AWS?
You need to have Python, pip, virtualenv, awswebcli and a SSH client installed to set up your Python Development Environment on AWS. You can follow instructions at http://docs.aws.amazon.com/elasticbeanstalk/latest/dg/eb-cli3-install.html to install these.
Once you have all those installed, you need to set up a virtual environment so that your global packages do not get polluted. Use the following command to set up a virtual environment:
$ virtualenv -p python2.7 /tmp/hello-world Running virtualenv with interpreter /usr/bin/python2.7 New python executable in /tmp/hello-world/bin/python2.7 Also creating executable in /tmp/hello-world/bin/python Installing setuptools, pip...done.
Once your virtual environment is ready, start it by running the activate script located in the environment's bin directory. For example, to start the hello-world environment created in the previous step, you would type:
$ . /tmp/hello-world/bin/activate
Once created, you can restart the virtual environment at any time by running its activate script again.
To configure a Python application for deployment, from within your virtualenv, return to the top of your project's directory tree and create a requirements.txt file that contains your app's requirements(third party modules you are importing) with their version numbers(or without if you need latest one). For example,
Flask==0.8 Jinja2==2.6 Werkzeug==0.8.3 certifi==0.0.8 chardet==1.0.1 : ...
Alternatively you can use pip to get all installed packages from your machine to the requirements.txt file using:
$ pip freeze >requirements.txt
This allows AWS to replicate your application's Python environment using the same packages and same versions that you used to develop and test your application.
Now configure AWS EB CLI repository with the 'eb init' command.
$ eb init -p python2.7 hello-world
Application hello-world has been created.
This command creates a new application named hello-world and configures your local repository to create environments with the latest Python 2.7 platform configuration. Run eb init again to configure a default keypair so that you can connect to the EC2 instance running your application with SSH
$ eb init Do you want to set up SSH for your instances? (y/n): y Select a keypair. 1) my-keypair 2) [ Create new KeyPair ]
Select a key pair if you have one already, or follow the prompts to create a new one. If you don't see the prompt or need to change your settings later, run eb init -i. Create an environment and deploy you application to it with eb create:
$ eb create hello-env
This command creates a load balanced Elastic Beanstalk environment named hello-env.
If you face any issues, you can check more detailed documentation here: http://docs.aws.amazon.com/elasticbeanstalk/latest/dg/create-deploy-python-django.html#python-django-configure-for-eb
- Related Articles
- Setting up C++ Development Environment
- How to Set Up and Configure Jekyll Development Site on Ubuntu 16.04
- How to set python environment variable PYTHONPATH on Windows?
- How to set python environment variable PYTHONPATH on Mac?
- How to set Python environment variable PYTHONPATH on Linux?
- How to set your python path on Linux?
- How to set your python path on Mac?
- How to set your python path on Windows?
- How to install JDK in Windows and set up the environment variables?
- How to Securely Set Up Your Home WiFi Router?
- How to set the GOPATH environment variable on Ubuntu?
- How to Securely Set Up Your Home Wi-Fi Router?
- How to Set-Up Shiny Server on Ubuntu
- What environment variables do I need to set up before I start running Java programs on my machine?
- How to set up openvpn on ubuntu 16 04