Using Virtual environment to build your python application for Azure

Python stack on Windows Azure is bare bones  and may not include all the libraries that your application may require. The best way to build your application for Azure is setting up a virtual environment for your application that you can deploy to Windows Azure website . Here is what you need to do to setup your own development environment for your application :

Install virtualenv

If you don’t have virutalenv installed , you can install it using PIP or Easy install tools . Make sure you have python setup tools installed for Python 2.7.x . Run the following command to install virtualenv

c:\python27>Scripts\easy_install virtualenv


c:\python27>Scripts\pip install virtualenv

Activate your Virtual Environment

After installing virtualenv, you can create a new development environment for your application . Go to the application folder and run the following command

virtualenv --no-site-packages myapp

Here, virtualenv creates a folder, myapp/, and sets up a clean copy of Python inside for you to use. It also installs the python setup tools so you can start building your own custom environment that includes all the modules you need for your application .

Activate your newly created environment  so you can begin working within it.


Now, you can  install any modules or libraries your application needs . For example if my application requires Flask , then run the command

pip install Flask

This will install Flask in the newly created environment under Lib/site-packages . Similarly you can install any module or library your application requires.

Known Issue  and Workaround

wfastcgi should does not enable .pth files in the user’s directory

Azure using as the FASTCGI handler for managing requests to your application . If the application modules are  installed as .EGG files , then wont be able to find the module you are using with your application . You can track the issue here

Workaround : You can install application using PIP or Easy install tools  and then rename the EGG files  as ZIP files . Now open the ZIP file and extract all the contents into site-packages folder .  


Leave a Reply

Fill in your details below or click an icon to log in: Logo

You are commenting using your account. Log Out / Change )

Twitter picture

You are commenting using your Twitter account. Log Out / Change )

Facebook photo

You are commenting using your Facebook account. Log Out / Change )

Google+ photo

You are commenting using your Google+ account. Log Out / Change )

Connecting to %s