Hi,
I realise this will probably cause me some backlash from the community but I have an issue which I am sure is environmental but have been struggling for a few days to resolve.
The back story is that I have successfully had Apache 2.4.37 installed on our server running mod_wsgi supporting an internal Django solution we are working on for quite some time.
Apache is running as a service on this server. Python was/is deployed via Anaconda virtual environment.The site has been configured as a Virtual Host
Everything works well. During the project life we cloned the setup into a DEV set of directories and created a second Windows Service to support that second environment. Nothing was shared in the sense that everything was setup and isolated in their own setr of directories.
The only thing that was shared was Python via the Virtual Environment. mod_wsgi was PIP installed into here after ensuring all of the appropriate VC libraries had been installed.
Apache 2.4.37 VC15 x64 was installed from an ApacheLounge binary distro.
Everything as far as i can tell is x64
Earlier this month I decided it was time to upgrade Django from 2.1.7 to 3.x. Our Apps are fairly basic and the whole environment pretty much out-of-the-box.
I created a new virtual environment and brought it up to Python 3.9 and upgraded Django and all of its dependencies at the same time. There were some challenges with some dependencies but I eventually got them all sorted.
I did as we did before and cloned the whole Apache folder, adjusted httpd.conf and httpd_hosts.conf which was typically just changing the various path names.
After stopping the existing DEV service I fired up httpd.exe from the command line after changing my working directory to the virtual environment hosting the updated python and Django site-packages. After some initial config issues - have it all running. The PROD service continues to run as well, pointing to the production version of the site using the older version of Django and site-packages.
As the existing Apache DEV service I had previously created affectively points to all of these directories and nothing has changed in how it starts. I simply left it as is.
The service will not start. When reviewing one of the logs I discovered what I believe to be the issue but I don't understand how to correct it as I believe I have done everything required for setting up mod_wsgi in embedded mode on Windows.
The error text indicates to me that the Python standard library .DLLs and .Lib directories are not correctly discovered as they indicate ".\\DDLs" and ".\\Lib". The sys.base_prefix is correct. Because of this I then get the import error. I don't believe wsgi.py even gets a chance to fire up properly.
I know there is a lot to consume here. But I have also included the relevant section from the httpd.conf and httpd_vhosts.conf files
WSGIApplicationGroup %{GLOBAL}
WSGIScriptAlias / "E:/tgm/sites/dev/django-agora/agora/wsgi.py"
<Directory E:/tgm/sites/dev/django-agora/agora>
<Files wsgi.py>
Require all granted
</Files>
</Directory>
ERROR LOG
Fri Jun 11 07:33:42.249667 2021] [wsgi:info] [pid 15408:tid 592] mod_wsgi (pid=15408): Initializing Python.
Python path configuration:
PYTHONHOME = (not set)
PYTHONPATH = (not set)
program name = 'python'
isolated = 0
environment = 1
user site = 1
import site = 1
sys._base_executable = 'E:\\tgm\\bin\\Apache24-DEV\\bin\\httpd.exe'
sys.base_prefix = 'E:\\tgm\\bin\\miniconda3\\envs\\agora-v3'
sys.base_exec_prefix = 'E:\\tgm\\bin\\miniconda3\\envs\\agora-v3'
sys.platlibdir = 'lib'
sys.executable = 'E:\\tgm\\bin\\Apache24-DEV\\bin\\httpd.exe'
sys.prefix = 'E:\\tgm\\bin\\miniconda3\\envs\\agora-v3'
sys.exec_prefix = 'E:\\tgm\\bin\\miniconda3\\envs\\agora-v3'
sys.path = [
'E:\\tgm\\bin\\miniconda3\\envs\\agora-v3\\python39.zip',
'.\\DLLs',
'.\\lib',
'E:\\tgm\\bin\\Apache24-DEV\\bin',
]
Fatal Python error: init_fs_encoding: failed to get the Python codec of the filesystem encoding
Python runtime state: core initialized
ModuleNotFoundError: No module named 'encodings'
HTTPD.CONF
LoadFile "e:/tgm/bin/miniconda3/envs/agora-v3/python39.dll"
LoadModule wsgi_module "e:/tgm/bin/miniconda3/envs/agora-v3/lib/site-packages/mod_wsgi/server/mod_wsgi.cp39-win_amd64.pyd"
WSGIPythonHome "e:/tgm/bin/miniconda3/envs/agora-v3"
HTTPD-VHOSTS.CONF
WSGIApplicationGroup %{GLOBAL}
WSGIScriptAlias / "E:/tgm/sites/dev/django-agora/agora/wsgi.py"
<Directory E:/tgm/sites/dev/django-agora/agora>
<Files wsgi.py>
Require all granted
</Files>
</Directory>
Thank-you in advance and again my apologies if I have over detailed things and not followed some specific requirements for the Windows environment. I am just after some hints as to what may lead to the incomplete paths being pushed into sys.path
Regards
Bruce