Question

i am following the tutorial found here: http://www.windowsazure.com/en-us/documentation/articles/cloud-services-web-sites-python-django-app-with-ptvs/

I already had django installed on my system. After following the instructions in this tutorial, i noticed that it seemed to have installed django again, but this time under my project's folder (myproject/env/Lib/site-packages). Why is this?

The other issue i am having is that if i try to import certain libraries using the visual studio editor, it's unable to find the import. However, if do this in the Interactive window, it does recognize the imports. Also, if create a stand-along python (not django) project, i am able to import the libraries fine. Any thoughts on why this is happening and how to resolve?

Was it helpful?

Solution

The tutorial uses Python virtual environments (virtualenv), which you need in order to deploy your website to Azure. A virtual environment, basically, is an isolated Python environment with its own set of libraries (site-packages etc) that is distinct from your main interpreter. It allows you to have specific versions of packages that you need just for that particular website, and different from the same for some other website of yours.

If you don't plan to deploy it to Azure, you don't need a virtual env - you can skip the step creating it, and instead install Django and other packages directly into your main interpreter. If you do plan to deploy to Azure, you need the virtual env, because the main interpreter installed on the Azure VM will not have any modules other than those in the standard library.

The reason why Python Interactive window lets you import the packages is that the instance you're working with is for your main interpreter. Every registered interpreter, and every virtual env in an opened project, has its own separate Python Interactive window. You can open the window for your virtual env from the Python Environments window, which is available via Tools -> Python Tools -> Python Environments.

Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top