Django 1.9 and Python 3.5

Repository of web frameworks and applications for Microsoft IIS.
User avatar
Posts: 11
Joined: 31 Aug 2016, 12:01

Django 1.9 and Python 3.5

31 Aug 2016, 12:13

Hi, I'm brand new to Helicon Zoo, found it while looking for a way to load my Django project onto IIS. I had a few questions though.

First, I'm using Python 3.5, but the web.config file only lists

<add name="python.project#x86" scriptProcessor="python.2.7.wsgi" path="*" verb="*" modules="HeliconZoo_x86" preCondition="bitness32" resourceType="Unspecified" requireAccess="Script" />
<add name="python.project#x64" scriptProcessor="python.2.7.wsgi" path="*" verb="*" modules="HeliconZoo_x64" preCondition="bitness64" resourceType="Unspecified" requireAccess="Script" />

under handlers. Do I just need to add a couple more lines, like

<add name="python.project#x86" scriptProcessor="python.3.5.wsgi" path="*" verb="*" modules="HeliconZoo_x86" preCondition="bitness32" resourceType="Unspecified" requireAccess="Script" />
<add name="python.project#x64" scriptProcessor="python.3.5.wsgi" path="*" verb="*" modules="HeliconZoo_x64" preCondition="bitness64" resourceType="Unspecified" requireAccess="Script" />

to enable Python 3.5, or is it more involved, or even possible?

I am also not sure how to change the environment variables. They all reference the environment variable %APPL_PHYSICAL_PATH%, but I don't see where that is set. Do I need to explicitly replace each one with the path to my Django project? Can I define that environment variable right in the config file, by adding a line like

<add name="APPL_PHYSICAL_PATH" value="C:\Django\MyFirstDjangoProject" />

or do I need to set it in powershell? Or is it implicitly set somewhere else?

Finally, and I'm really just confirming this, but I used a different name for my venv directory; I'm assuming I can/need to just change the config file also to reflect that, like

<add name="VIRTUAL_ENV" value="%APPL_PHYSICAL_PATH%\MyNewVENVDirectoryName" />

and similarly for the PATH. Is that right?

User avatar
Posts: 11
Joined: 31 Aug 2016, 12:01

Re: Django 1.9 and Python 3.5

31 Aug 2016, 12:57

I should also add that I installed through Web Platform Installer. I then found a forum post about Python 3.4 saying that there was a new standalone installer, but I don't know how important that is.

User avatar
Posts: 402
Joined: 06 Mar 2012, 11:59

Re: Django 1.9 and Python 3.5

01 Sep 2016, 09:23

Hello.

Please try Zoo version 4 instead: https://github.com/helicontech/zoo/releases
It currently offers Python 3.4 (not a big difference to 3.5) and it would be much easier to update to 3.5 if required. There is no documentation, but I hope the UI itself is quite self-describing. Please try Zoo -> Applications -> Template -> Python Project to install empty python project on IIS and then open it in the browser and follow instructions on the home page. Changing virtual environment also imply changing PATH and PYTHONPATH variables. You'll see it in your site's properties in Zoo.

User avatar
Posts: 11
Joined: 31 Aug 2016, 12:01

Re: Django 1.9 and Python 3.5

16 Sep 2016, 09:02

Sorry, I downloaded the package and installed it, but it's completely unintuitive how to proceed. Some guidance would be appreciated.

User avatar
Posts: 402
Joined: 06 Mar 2012, 11:59

Re: Django 1.9 and Python 3.5

16 Sep 2016, 09:51

Oh, sorry.
Please tell me more what kind of difficulties you are experiencing so I may think of a better UX.
Have you run the program? Have you installed an application as I said: Applications -> Template -> Python project? Did you have any troubles filling installation forms? Did you open resulting website?

User avatar
Posts: 11
Joined: 31 Aug 2016, 12:01

Re: Django 1.9 and Python 3.5

21 Sep 2016, 10:17

I will endeavor to write up a detailed list of my steps with some screenshots, but I won't have time to do it until Friday morning Eastern time. Thanks for your continued responsiveness :)

User avatar
Posts: 11
Joined: 31 Aug 2016, 12:01

Re: Django 1.9 and Python 3.5

23 Sep 2016, 10:37

OK, sorry for the delay. I am at the main screen, with menus for Applications, Products, and My Server. I THINK I want to install My Server/Python 3.4 FastCGI Engine, but beyond that, I'm really not sure. Even that I'm not actually sure about, because I am using Python 3.5. The other issue is that Django 1.9 does not use FastCGI, only WSGI. It says that it is for WSGI applications, though, so if I'm interpreting it correctly, it will work, because HZ converts a WSGI interface on Django's side into a FastCGI interface on interface on IIS's side.

I don't think I want to install Django, because I already have it installed and working (with the built-in development server that comes with it), and I don't know what version HZ would install anyway; I have Django 1.9. I also have a virtual environment setup and it's connected to version control. In short, all the pieces to my project are already assembled (well, it's a continuing work in progress, but still), and a fresh install would just muddy things up. What I was expecting/hoping for, was just a module to install that had some options like where the wsgi and settings files of my Django project were located, and I could just type that in, click ok, and have it work.

I also see a sidebar with a collapsible tree that I'm not exactly sure what to do with:

Image

The DataGovernance is my application. I was messing around with IIS before, and tried a few things; I don't remember exactly what I did. I'm hoping HZ is the answer, as I've been at this for quite a while :)

Thank you for all your help!

edit: I also don't know about the other things. Specifically, I'm wondering if I should install Products/Helicon Zoo module for IIS. It seems like I would need it, but it also seems so essential it would be installed by default, so I may be missing something.

User avatar
Posts: 402
Joined: 06 Mar 2012, 11:59

Re: Django 1.9 and Python 3.5

26 Sep 2016, 08:11

Hi.

My response will include answers to your private message as I think we can safely continue here:

1. My Server section is for managing your server settings and installed websites and applications. In your case you are creating a new application, so yes, you need to do Applications -> Template -> Python Project.

2. Since you have created the application in the folder, then deleted it, then probably moved to another location, your IIS configuration may point to the wrong location, that is why HZ is complaining about "System cannot find the path". I strongly recommend you to create a new application in a new website, instead of using default website - that way you get less interference with what you have already configured in your system. You don't need to create a new website manually, Zoo will do this automatically if you choose "Create new site" on the second step of application (Python project) installation. Please choose another port for this website (like 8081) so you will be able to access it as http://localhost:8081/

3. After installation is completed you will be directed to the website settings page in HZ. There you should see "Browse" button. Click it and you should see your new website created already running on Python 3.4.

4. Follow instruction under "Running existing Django project". In general, you will need to copy your existing Django application files over to the folder of this new website. Then open Zoo console and run "pip install -r requirements.txt" (I guess you have requirements.txt in your project). Then specify WSGI_HANDLER and DJANGO_SETTINGS_MODULE in accordance with your project's name as explained in "Running existing Django project" instruction. Refresh and you should see your application running.

User avatar
Posts: 11
Joined: 31 Aug 2016, 12:01

Re: Django 1.9 and Python 3.5

26 Sep 2016, 11:31

Thanks! I finally got it working, but I had to create a new site like you said, even on a different computer with a fresh IIS install; I kept getting the same "not found" errors when I tried to use the default web site. It has been requested to make it work on the Default Web Site, but for now I'll settle for getting it working. I must now return to my normal duties, but tomorrow I will see about installing Django (I have the placeholder HZ page now). Now, my Django still uses Python 3.5; any advice on how to deal with that fact? Should it just work, if for example the HZ connector uses one python but Django uses another? Can that happen? Or do I need to move everything to the same version? If so, how would I do that? Again, my emphasis now is on getting it working with a minimum of changes to my current project.

User avatar
Posts: 402
Joined: 06 Mar 2012, 11:59

Re: Django 1.9 and Python 3.5

27 Sep 2016, 07:35

Hello.

1. Regarding "System cannot find the path..." error when installing an application in a subfolder, I now think it is a bug in Zoo which I will fix soon.
2. Regarding Python 3.5, I'm not sure what you mean when saying your Django project uses Python 3.5, does it actually using some of intrinsic 3.5 version features? If no, then it will probably just work on any Python version supplied as Python projects normally do not have a dependency on exact Python version. Anyway I will probably upgrade Python version included into Zoo repository, so you could update your Python installation automatically later.

User avatar
Posts: 11
Joined: 31 Aug 2016, 12:01

Re: Django 1.9 and Python 3.5

27 Sep 2016, 14:29

OK, I followed the instructions on the Intro page, but it doesn't work. Here's what I did:

My directory structure, in relevant part, looks like this:

C:
--inetpub
----DataGovernance
------DataGovernance_sample (this used to be named DataGovernance, I renamed it; it had the files created by HZ by default)
------DataGovernance (this contains a carbon copy of my entire Django project, including the virtual environment)
----Default Web Site
----wwwroot
------<IIS placeholder page files>

I first insured that Python 3.4 FastCGI engine had a box around it and a checkmark, when I clicked on DataGovernance in HZ. I then made the following changes to environment variables:
PYTHONPATH
%APPL_PHYSICAL_PATH%\venv\lib\site-packages;%APPL_PHYSICAL_PATH%\venv\lib;%APPL_PHYSICAL_PATH%;%APPL_PHYSICAL_PATH%\project -->
%APPL_PHYSICAL_PATH%\venv\lib\site-packages;%APPL_PHYSICAL_PATH%\venv\lib;%APPL_PHYSICAL_PATH%;%APPL_PHYSICAL_PATH%\DataGovernance

WSGI_HANDLER welcome.application --> DataGovernance.wsgi.application

DJANGO_SETTINGS_MODULE: DataGovernance.settings

Then I go to localhost/DataGovernance/imports/weekly (imports/weekly being routed in my urls file:
...
url(r'^(?i)Imports/', include('Imports.urls')),
...

# Imports.urls
...
url(r'^(?P<import_frequency>monthly|weekly)$', views.IndexView.as_view(), name='web'),
...

)

However, it doesn't work. I did notice that my new directory, with the copy of my project, no longer registers in HZ as having the correct handler active. In fact, it only has the Install New Zoo Application Here button. I think I put my project directory in the wrong place, but I don't want to mess up what's already there as boilerplate. So where exactly in the above procedure did I go wrong? I have also not gone through any virtual environment changes; I gather that I will have to completely reinstall all modules from scratch, and scrap my current virtual environment; is that right?

User avatar
Posts: 402
Joined: 06 Mar 2012, 11:59

Re: Django 1.9 and Python 3.5

29 Sep 2016, 08:51

Hi.

Because of the bug I mentioned in the previous post it is now impossible to create Zoo application in a subfolder of a website. Well, actually it is possible but only for sites named the same as their folder name (which in the case of "Default web site" is not true). I will fix this bug soon, meanwhile, please only create Zoo applications in the root of a website (newly created or existing).
I'm not sure where exactly things went wrong with your installation now. Can I please have RDP access to that server? I suppose it is not production so it is safe to experiment on it?

User avatar
Posts: 11
Joined: 31 Aug 2016, 12:01

Re: Django 1.9 and Python 3.5

29 Sep 2016, 10:14

It's an internal machine, and even if I could give you any kind of access, my boss and the IT people would completely lose their minds that I gave any kind of access to our network to someone outside the company. I would set up on a personal server, but I have completely made the jump to linux, so that's also not possible. Was my diagram of the directory structure clear? I really think I just didn't put things in the right place. I also noticed that the DataGovernance_sample, which contains everything created by HZ, still has the configuration panels that it did before, even after renaming. This makes me think that there is some file or files in that directory that I need, but I don't know which ones I need and which I can overwrite.

User avatar
Posts: 402
Joined: 06 Mar 2012, 11:59

Re: Django 1.9 and Python 3.5

30 Sep 2016, 08:54

Reading your directory structure it remains unclear to me where you have installed HZ website and where have you copied your Django project?
Actually, the scenario is the following:
1. You install HZ Python Project in the root of a freshly created website.
2. Navigate to this website to confirm HZ Python project is working - you should see welcome page and instructions.
3. Copy your Django project right in the root folder of this website, overwriting files if needed. I understand your project contains virtualenv, however, most likely it has to be recreated under Zoo. HZ Python project already includes virtualenv that will be used to run an application. So you may experience issues with inconsistent versions of modules installed. You are suggested to create requirements.txt file and run "pip install -r requirements.txt" command from Zoo console (available from HZ page of your website) every time you need to establish a new copy of your application. this is generally a bad idea to deploy virtualenv with your application instead of calling 'pip install', because under different platforms and python versions virtualenv may contain incompatible files.
4. Modify environment variables as instructed above. These variables can be found under website properties in HZ.
5. After variables modification and refreshing the site you should see your application (or at least error message from your application). And don't forget to turn IIS detailed errors on, otherwise you will only see truncated messages with no information

User avatar
Posts: 11
Joined: 31 Aug 2016, 12:01

Re: Django 1.9 and Python 3.5

03 Oct 2016, 15:00

Hahah! I finally got it working, thank you for all your help and patience. I did indeed have to just overwrite everything, and use the HZ virtual environment. There were a couple other annoying things related to the Django itself, but I know have a functional Django hosted on IIS.

User avatar
Posts: 11
Joined: 31 Aug 2016, 12:01

Re: Django 1.9 and Python 3.5

03 Oct 2016, 18:53

Well it would seem that I spoke too soon :/

I tried to reproduce my installation procedure, and tore everything down as best I could without actually reinstalling my machine. I uninstalled HZ and IIS, and deleted the inetpub directory (actually I just renamed it so I still have it). Then I reinstalled IIS, and then HZ. Then I tried to install the python sample project like before, but this time around IIS is giving me 403 errors. It looks like it's trying to just browse to the directory, almost like on this second go-around, IIS doesn't know to do anything special other than serve up static files. Any idea what might be causing this? My next step will be to try on yet another fresh computer, hopefully I can get a virtual box up and running, but I'm trying to just get a working procedure on my own machine.

User avatar
Posts: 11
Joined: 31 Aug 2016, 12:01

Re: Django 1.9 and Python 3.5

05 Oct 2016, 16:24

OK, I have a sneaking suspicion about something. I got it to work again, but only by allowing HZ to install IIS itself. But when I try to install with IIS that has already been installed, it gives me these errors:

http://imgur.com/a/3nqwQ

Does HZ require anything special about IIS, like a particular version or feature to be enabled/disabled? It said my version of IIS was 10.0 in the prerequisites stage of installing the sample app.

User avatar
Posts: 402
Joined: 06 Mar 2012, 11:59

Re: Django 1.9 and Python 3.5

21 Oct 2016, 12:02

Hello.

Sorry for the delay. According to error message you are trying to create new website with the name "DataGovernance" while site with this name already exist. You need to choose install into existing website option instead of creating new or choose different name.

Return to Helicon Zoo

Who is online

Users browsing this forum: No registered users and 1 guest