Azure website use python3 with django - python

Officially, Azure Django Websites only support Python 2.7 and Django 1.4, but I am wondering if it is possible to set up an Azure Django website using Python 3.3 and Django 1.6 instead. This official Azure tutorial states:
Note: Windows Azure web sites now come with Python 2.7 and wfastcgi handler
pre-installed. However, web frameworks such as Django are not included. You can
still use a different Python interpreter if you prefer. You just need to include
it in the Git repository and configure the web site to use that interpreter
instead of the Python 2.7 interpreter already installed.
That sounds to me like you can set it up to use a different Python interpreter, although you may have to also provide your own wfastcgi handler and Django installation if you do this. The tutorial also tells you how to point to the location of the interpreter you want to use.
The Python website provides installers, but how would I get everything needed for the Python interpreter into one folder to put in the git repo? Is everything needed already self-contained in /Library/Frameworks/Python.framework/Versions/3.3? What about for Django and wfastcgi? Has anyone else tried this?

It is working now: put python-3.4 in runtime.txt at the root of the project.
See: https://azure.microsoft.com/en-us/documentation/articles/web-sites-python-configure/

Related

How to make flask app with projects written in two different Python versions work in endpoints?

I’m building a flask api in which I have to use two different Python projects written in 2 different versions. One is a Python project built on version 3.8+, and another is a proprietary package compatible for version <3.7. I get errors if I use a single version and try to run it, and fixing errors would be too much and potentially break the system behavior. The flask api runs on docker. What are my options to make both Python projects work on the single flask app?
If you have multiple dependencies that are incompatible (e.g. one requires Python >= 3.8, one < 3.8), then you can't use them in the same Flask server.
Flask runs with Python, and therefore you need to select one Python version with one set of compatible dependencies.
Some potential solutions to your project:
Choose some alternative packages that is compatible with your Python version.
If you have access to one of those dependencies (e.g. by modifying the original project directly, or fork them if it's an open source project), try to make them compatible with the Python version that you have.
Run 2 Flask servers instead of just one. E.g. one with Python 3.7, that implements the endpoint which requires the old dependency, and one Python 3.8 Flask server, that implements the other endpoint and just redirects the 3.7 requests to the other server. Alternative you could also use something like Nginx to split the requests between the servers.

App Engine is not supported for python 3 in pycharm

I want to create a google app engine project in pycharm. I select python 3, give my project a name.
And it's written that App Engine is not supported for the selected interpreter
I can choose python 2.7 and it is working but why can't I choose python 3.6? I even tried 3.5, same problem. However in official documentation it supports python 3.6...
I'm sure I have installed google app flexible environment
I'll leave there a screen of pycharm just in case gdrive link
AFAIK PyCharm's GAE support means:
ability to run/debug a GAE app project using the SDK's dev_appserver.py - which is only supported for the standard environment
ability to deploy on GAE using the SDK utilities - which not long ago didn't even support well apps with multiple standard environment services - I had to deploy my app manually.
In other words PyCharm doesn't offer real/significant benefits for the flexible env GAE apps, you'll have to complement it with manual ops or scripts anyways.
So I'd just create a regular python 3.5/3.6 project and simply not specify it's also a GAE project.

Configuring Azure for Django/Python 3

I had a Django project that uses python 3.2+. Having been through a couple Azure classes I wanted to deploy my Django application through Windows Azure. I got the web site synced through my Git Repository, and following the advice of the MSDN forums, added the python 33 runtime in a folder called /PythonCore/ and added WSCGI.py to the scripts folder within there.
My website can''t find the CGI interface and likewise is failing to process HTTP requests. I know something must be wrong in my configuration, but I havn't a clue as to what. I was wondering if anyone might know what my error is.
WEBSITE_NODE_DEFAULT_VERSION 0.10.5
DJANGO_SETTINGS_MODULE DjangoApplication.settings
PYTHONPATH D:\home\site\wwwroot\DjangoApplication;
WSGI_HANDLER django.core.handlers.wsgi.WSGIHandler
Handler Mappings
* D:\home\site\wwwroot\PythonCore\python.exe D:\home\site\wwwroot\PythonCore\scripts\wfastcgi.py
Please let me know if any additional information is needed or you have an idea what I can try.
Azure Web Sites w Django currently requires Python version 2.7. Please see this:
http://www.windowsazure.com/en-us/develop/python/tutorials/web-app-with-django-and-mysql/
and
http://pytools.codeplex.com/wikipage?title=Django%20Web%20Site/Cloud%20Service%20Tutorial
Corresponding video walk thru:
http://www.youtube.com/watch?v=S7A7VNnsA_8
Python 3.x will be supported soon (hopefully fall 2013).

How do I setup a local Django development environment on Ubuntu?

Finally made the switch from Windows to Linux (Ubuntu). I am teaching myself Python + Django.
GOAL: I want to setup a local development environment where I can build a django application and run it locally before deploying it live online.
SO FAR: Python comes installed with Linux. Gedit does also. Ok great. After that I am lost.
I am not sure how to proceed. I am a total Linux noob. I am guessing I need apache running, mysql running, and django to run. I don't know how to setup these things to run or how to set the proper directories or what I need to link to what... really I am not even sure what the right questions are to ask.
Quick answer:
Just install django via their documentation, and you will not even need apache running as it will run its own server. You can use sqlite as a db and you won't even have to worry about mysql. This is if your goal is to learn django and get things running asap.
Otherwise, if you want to take the full route, you'll need to start learning a lot more (which isn't a bad thing). I'd say take a look at some of the slicehost guides for setting up apache, mysql in ubuntu:
http://articles.slicehost.com/2010/5/19/installing-apache-on-ubuntu
http://articles.slicehost.com/2011/3/10/installing-mysql-server-on-ubuntu
And then pick up with just installing django and going from there. The django tutorial is awesome. There's plenty of other documentation out there on the web & tutorials for setting up dev environments.
Assuming you have python
You can install pip:
easy_install pip
From now you can use pip to install your python libraries for example to install django
pip install django
For development I would prefer pydev, it has a support for django with the power of eclipse.

How can Django projects be deployed with minimal installation work?

To deploy a site with Python/Django/MySQL I had to do these on the server (RedHat Linux):
Install MySQLPython
Install ModPython
Install Django (using python setup.py install)
Add some directives on httpd.conf file (or use .htaccess)
But, when I deployed another site with PHP (using CodeIgniter) I had to do nothing. I faced some problems while deploying a Django project on a shared server. Now, my questions are:
Can the deployment process of Django project be made easier?
Am I doing too much?
Can some of the steps be omitted?
What is the best way to deploy django site on a shared server?
To enable easy Django deployement I would to the following:
Fisrt-time server configuration
Install mod_wsgi which allow you to run in embedded mode OR in daemon mode.
Install python and virtualenv
In your development environment
Use virtualenv. Take a look at mod_wsgi and virtualenv configuration
Install Django your django version (using python setup.py install)
Install your python libs
Develop your project
Every time you want to deploy
Copy your virtual environment to the production server
Just add an Include directive in your httpd.conf file (or use .htaccess) to your project's apache configuration. As stated in mod_wsgi integration with django documentation, one example of how Apache included file could be configured would be:
Alias /media/ /usr/local/django/mysite/media/
<Directory /usr/local/django/mysite/media>
Order deny,allow
Allow from all
</Directory>
WSGIScriptAlias / /usr/local/django/mysite/apache/django.wsgi
<Directory /usr/local/django/mysite/apache>
Order deny,allow
Allow from all
</Directory>
Automating deployement
I would consider using Fabric to automate deployement
Can the deployment process of django project be made easier?
No. You can script some of this, if you want. However, you're never going to install MySQL, MySQLPuthon, mod_wsgi (or mod_python), or Django again.
You will, however, tweak your application all the time.
Am I doing too much?
No. Python (and Django) are not part of Apache. PHP is embedded in Apache. PHP is exactly like mod_python (or mod_wsgi). Just one piece of the pie. (Apparently, some hosts handle the PHP installation for you, but don't handle the mod_wsgi or mod_python installation.)
Can some of the steps be omitted?
No. However, you only do it once.
What is the best way to deploy django site on a shared server?
You're doing it correctly.
When I deployed another site with php (using CodeIgniter) I had to do nothing
Certainly an unfair comparison. Apparently, they already installed PHP and the database for you. Nice of them.
Also, PHP is not Python. PHP is a plug-in to Apache. Python is "just" a programming language, that requires a separate plug-in to Apache (i.e., mod_python or mod_wsgi).
See How nicely does Python 'flow' with HTML as compared to PHP?
Django hosting support is not as widespread as for PHP, but there are some good options. I can recommend WebFaction - they provide an easy-to-use control panel which offers various combinations of Django versions, Python versions, mod_python, mod_wsgi, MySQL, PostgreSQL etc. They're cost-effective, too. If you use their setup, you get SSH access but just about all of the setting up can be done via their control panel, apart from the actual uploading of your project folder.
Disclaimer: apart from being a happy customer I have no other connection with them.
You didn't have to do anything when deploying a PHP site because your hosting provider had already installed it. Web hosts which support Django typically install and configure it for you.
You just install this already made solution if your allowed to run an image on a virtual machine. I can imagine installations will be done this way in future as complicated security configuration can be done automatically.
Most shared hosting sites run the LAMP (Linux, Apache, MySQL, PHP) stack so deployment is just a matter of copying some files over. If you were using one of the PHP frameworks like CakePHP or something the service hasn't installed (like an imaging library) you'd be going through extra deployment steps as well.
With Django (or Rails, or any other complex framework) you have to set up the stack yourself that one time, then you're good to go.
However, you'll also want to think about post-deployment updating. If it's something you're going to do often you may also want to look into Fabric or Capistrano to help automate that.
P.S. I'll second that WebFaction recommendation. It's as close to one-button installation as I've seen. Pretty happy customer although I mostly use them for test-sites and prototyping.
You can use Python virtualenv and pip (see also "Tools of the Modern Python Hacker: Virtualenv, Fabric and Pip"). I developed my Django project in the virtual environment. I copy the virtual environment file to the production machine when I deploy my application. I use mod_wsgi. You must write that in the mod_wsig file:
import site
site.addsitedir('C:\PythonVirtualEnv\IntegralEnv\Lib\site-packages')

Categories