Hi Graham,
Thank you for your quick response.
Ok, so I did a couple things:
1) Set WSGIPythonHome
= "c:/users/administrator/appdata/local/programs/python/python37" in
httpd.conf
2) Removed WSGIApplicationGroup %{GLOBAL} from VirtualHost configuration
Once I did that, I actually did not get the "encodings" error I was getting
before. However, I got an Internal Server Error. I assumed this happened
because the main Python interpreter didn't have the necessary modules that
the virtualenv did have (thus, I pip installed them).
Now I am getting the following error:
File "C:\\CRM4_Flask\\venv\\Lib\\site-packages\\uuid.py", line 138\r,
referer: http://172.16.3.120/
[Tue Sep 15 06:54:38.538334 2020] [wsgi:error] [pid 6244:tid 1228] [client
] if not 0 <= time_low < 1<<32L:
SyntaxError: invalid syntax\r, referer: http://ip/
This is apparently happening in uuid module, which in theory has nothing to
do with my app. I guess it is a built in module or something. What can i do?
On Tuesday, September 15, 2020 at 6:31:10 AM UTC-6 Graham Dumpleton wrote:
>
>
> > On 15 Sep 2020, at 10:17 pm, Daniel Gutiérrez <
> [email protected]> wrote:
> >
> >
> > Hi, I want to host multiple Flask apps through Apache in the same
> Windows 10 server. I want each app to be running on different ports. I
> figured that each app must have its own Python configuration, otherwise
> Apache will only run one of the two web apps. I have seen that in Linux you
> are supposed to use WSGIDaemonProcess command in the VirtualHost file, but
> this does not work on Windows.
> >
> > I tried using
> >
> > import sys
> > activate_this = 'C:/CRM4_Flask/venv/Scripts/activate_this.py'
> > with open(activate_this) as file_:
> > exec(file_.read(), dict(__file__=activate_this))
> >
> > #Expand Python classes path with your app’s path
> > # The string inputted as the parameter corresponds to the web app's path
> in C
> > sys.path.insert(0, "C:/CRM4_Flask")
> >
> > from run import app as application
> >
> > in my run.wsgi file for each app. However, I always get the following
> error:
> >
> > Fatal Python error: initfsencoding: unable to load the file system codec
> > ModuleNotFoundError: No module named 'encodings'
>
> This error has nothing to do with use of activate_this files and indicates
> that the Python libraries can't find your Python installation for some
> reason.
>
> Still set WSGIPythonHome, but set it to where the main Python installation
> is located (not the virtual environment).
>
> This should be the value of sys.prefix, or at least I hope so as I can't
> remember what Windows uses for the main Python installation.
>
> > What alternative do I have instead of using WSGIDaemonProcess, given
> that it does not work on Windows? Im using Apache 2.4, Python 3.7.7,
> Windows 10 and mod_wsgi 4.7.1
> >
> > My VirtualHost configuration for one of the web apps I want to host is:
> >
> >
> > <VirtualHost *:80>
> >
> > ServerName localhost:80
> > ServerAlias localhost:80
> > ServerAdmin [email protected]
> >
> > DocumentRoot c:/CRM4_Flask
> >
> > <Directory c:/CRM4_Flask>
> > Require all granted
> > </Directory>
> >
> > WSGIScriptAlias / c:/CRM4_Flask/run.wsgi
> > WSGIApplicationGroup %{GLOBAL}
>
> Provided that both your WSGI applications only use third party modules
> that work fine in sub interpreters, all you need to do is NOT set
> WSGIApplicationGroup.
>
> So long as you don't set it, each WSGI application will run in a separate
> Python sub interpreter of the same process and in the main shouldn't
> interfere with each other, or at least to the extent that sub interpreters
> separate things.
>
> This is because sub interpreters are used by default, where the name of
> the sub interpreter is based on the name of the virtual host, the port, and
> the mount point of the WSGI application. So long as your two virtual hosts
> are on different ports (except for 80/443 which are still treated as one),
> they should be separate.
>
> If you are using Python packages such as numpy then you will have a
> problem though. This is because numpy and thus a lot of the scientific
> packages for Python don't work in sub interpreters. Usually with those you
> would force the use of the main Python interpreter context. This is fine on
> Linux where have multiple apps which all need that to be done, as you can
> delegate each to separate daemon process groups. On Windows though you
> would be out of luck, as only one could be delegated to the main Python
> interpreter.
>
> The directive which delegates the WGSI application to the main interpreter
> is:
>
> WSGIApplicationGroup %{GLOBAL}
>
> which is why I am asking you not to set it, cause right now you are
> telling both to run in the main interpreter, so they will conflict.
>
> Graham
>
>
> > <Directory c:/CRM4_Flask>
> > Options +FollowSymLinks
> > Require all granted
> > </Directory>
> >
> > ErrorLog "logs/crm4-error.log"
> > CustomLog "logs/crm4-access.log" common
> >
> > </VirtualHost>
> >
> > In the httpd.conf I added the following lines:
> >
> > LoadFile
> "c:/users/administrator/appdata/local/programs/python/python37/python37.dll"
> > LoadModule wsgi_module
> "c:/crm4_flask/venv/lib/site-packages/mod_wsgi/server/mod_wsgi.cp37-win_amd64.pyd"
> > #WSGIPythonHome "c:/crm4_flask/venv"
> >
> > I commented WSGIPythonHome because in theory I need Apache to load two
> versions of Python, not only one.
> >
> > Please let me know if I am doing something wrong or if I should try
> something else.
>
>
--
You received this message because you are subscribed to the Google Groups
"modwsgi" group.
To unsubscribe from this group and stop receiving emails from it, send an email
to [email protected].
To view this discussion on the web visit
https://groups.google.com/d/msgid/modwsgi/bc1efda6-62b0-444c-8981-a9eb47ff7bd2n%40googlegroups.com.