Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Problem to "deploy" using mod_wsgi on windows server 2019 local network. #845

Open
PantaneiroCG opened this issue Jul 3, 2023 · 18 comments

Comments

@PantaneiroCG
Copy link

PantaneiroCG commented Jul 3, 2023

I've been trying to put my django application in production for weeks and I got this situation:

Apache Lounge Version 2.4
Python 3.11
Error log:

[Mon Jul 03 13:33:05.482189 2023] [wsgi:error] [pid 10664:tid 1248] [client ::1:53012] mod_wsgi (pid=10664): Failed to exec Python script file 'C:/Apache24/htdocs/Cadastro/projeto_cad_usuarios/projeto_cad_usuarios/wsgi.py'.
[Mon Jul 03 13:33:05.482189 2023] [wsgi:error] [pid 10664:tid 1248] [client ::1:53012] mod_wsgi (pid=10664): Exception occurred processing WSGI script 'C:/Apache24/htdocs/Cadastro/projeto_cad_usuarios/projeto_cad_usuarios/wsgi.py'.
[Mon Jul 03 13:33:05.483187 2023] [wsgi:error] [pid 10664:tid 1248] [client ::1:53012] Traceback (most recent call last):\r
[Mon Jul 03 13:33:05.484185 2023] [wsgi:error] [pid 10664:tid 1248] [client ::1:53012]   File "C:/Apache24/htdocs/Cadastro/projeto_cad_usuarios/projeto_cad_usuarios/wsgi.py", line 16, in <module>\r
[Mon Jul 03 13:33:05.484185 2023] [wsgi:error] [pid 10664:tid 1248] [client ::1:53012]     application = get_wsgi_application()\r
[Mon Jul 03 13:33:05.484185 2023] [wsgi:error] [pid 10664:tid 1248] [client ::1:53012]                   ^^^^^^^^^^^^^^^^^^^^^^\r
[Mon Jul 03 13:33:05.484185 2023] [wsgi:error] [pid 10664:tid 1248] [client ::1:53012]   File "C:\\Apache24\\htdocs\\Cadastro\\env\\Lib\\site-packages\\django\\core\\wsgi.py", line 12, in get_wsgi_application\r
[Mon Jul 03 13:33:05.484185 2023] [wsgi:error] [pid 10664:tid 1248] [client ::1:53012]     django.setup(set_prefix=False)\r
[Mon Jul 03 13:33:05.484185 2023] [wsgi:error] [pid 10664:tid 1248] [client ::1:53012]   File "C:\\Apache24\\htdocs\\Cadastro\\env\\Lib\\site-packages\\django\\__init__.py", line 19, in setup\r
[Mon Jul 03 13:33:05.484185 2023] [wsgi:error] [pid 10664:tid 1248] [client ::1:53012]     configure_logging(settings.LOGGING_CONFIG, settings.LOGGING)\r
[Mon Jul 03 13:33:05.484185 2023] [wsgi:error] [pid 10664:tid 1248] [client ::1:53012]                       ^^^^^^^^^^^^^^^^^^^^^^^\r
[Mon Jul 03 13:33:05.484185 2023] [wsgi:error] [pid 10664:tid 1248] [client ::1:53012]   File "C:\\Apache24\\htdocs\\Cadastro\\env\\Lib\\site-packages\\django\\conf\\__init__.py", line 57, in __getattr__\r
[Mon Jul 03 13:33:05.484185 2023] [wsgi:error] [pid 10664:tid 1248] [client ::1:53012]     self._setup(name)\r
[Mon Jul 03 13:33:05.484185 2023] [wsgi:error] [pid 10664:tid 1248] [client ::1:53012]   File "C:\\Apache24\\htdocs\\Cadastro\\env\\Lib\\site-packages\\django\\conf\\__init__.py", line 44, in _setup\r
[Mon Jul 03 13:33:05.484185 2023] [wsgi:error] [pid 10664:tid 1248] [client ::1:53012]     self._wrapped = Settings(settings_module)\r
[Mon Jul 03 13:33:05.484185 2023] [wsgi:error] [pid 10664:tid 1248] [client ::1:53012]                     ^^^^^^^^^^^^^^^^^^^^^^^^^\r
[Mon Jul 03 13:33:05.484185 2023] [wsgi:error] [pid 10664:tid 1248] [client ::1:53012]   File "C:\\Apache24\\htdocs\\Cadastro\\env\\Lib\\site-packages\\django\\conf\\__init__.py", line 107, in __init__\r
[Mon Jul 03 13:33:05.484185 2023] [wsgi:error] [pid 10664:tid 1248] [client ::1:53012]     mod = importlib.import_module(self.SETTINGS_MODULE)\r
[Mon Jul 03 13:33:05.484185 2023] [wsgi:error] [pid 10664:tid 1248] [client ::1:53012]           ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^\r
[Mon Jul 03 13:33:05.485181 2023] [wsgi:error] [pid 10664:tid 1248] [client ::1:53012]   File "C:\\Python311\\Lib\\importlib\\__init__.py", line 126, in import_module\r
[Mon Jul 03 13:33:05.485181 2023] [wsgi:error] [pid 10664:tid 1248] [client ::1:53012]     return _bootstrap._gcd_import(name[level:], package, level)\r
[Mon Jul 03 13:33:05.485181 2023] [wsgi:error] [pid 10664:tid 1248] [client ::1:53012]            ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^\r
[Mon Jul 03 13:33:05.485181 2023] [wsgi:error] [pid 10664:tid 1248] [client ::1:53012]   File "<frozen importlib._bootstrap>", line 1206, in _gcd_import\r
[Mon Jul 03 13:33:05.485181 2023] [wsgi:error] [pid 10664:tid 1248] [client ::1:53012]   File "<frozen importlib._bootstrap>", line 1178, in _find_and_load\r
[Mon Jul 03 13:33:05.485181 2023] [wsgi:error] [pid 10664:tid 1248] [client ::1:53012]   File "<frozen importlib._bootstrap>", line 1128, in _find_and_load_unlocked\r
[Mon Jul 03 13:33:05.485181 2023] [wsgi:error] [pid 10664:tid 1248] [client ::1:53012]   File "<frozen importlib._bootstrap>", line 241, in _call_with_frames_removed\r
[Mon Jul 03 13:33:05.485181 2023] [wsgi:error] [pid 10664:tid 1248] [client ::1:53012]   File "<frozen importlib._bootstrap>", line 1206, in _gcd_import\r
[Mon Jul 03 13:33:05.485181 2023] [wsgi:error] [pid 10664:tid 1248] [client ::1:53012]   File "<frozen importlib._bootstrap>", line 1178, in _find_and_load\r
[Mon Jul 03 13:33:05.485181 2023] [wsgi:error] [pid 10664:tid 1248] [client ::1:53012]   File "<frozen importlib._bootstrap>", line 1142, in _find_and_load_unlocked\r
[Mon Jul 03 13:33:05.485181 2023] [wsgi:error] [pid 10664:tid 1248] [client ::1:53012] ModuleNotFoundError: No module named 'projeto_cad_usuarios'\r

mod_wsgi.py

import os

from django.core.wsgi import get_wsgi_application

os.environ.setdefault('DJANGO_SETTINGS_MODULE', 'projeto_cad_usuarios.settings')

application = get_wsgi_application()

httpd.conf

Alias /robots.txt "C:/Apache24/htdocs/Cadastro/projeto_cad_usuarios/static/robots.txt"
Alias /favicon.ico "C:/Apache24/htdocs/Cadastro/projeto_cad_usuarios/static/favicon.ico"

Alias /media/ "C:/Apache24/htdocs/Cadastro/projeto_cad_usuarios/media/media"
Alias /static/ "C:/Apache24/htdocs/Cadastro/projeto_cad_usuarios/static/"

<Directory "C:/Apache24/htdocs/Cadastro/projeto_cad_usuarios/static">
Require all granted
</Directory>

<Directory "C:/Apache24/htdocs/Cadastro/projeto_cad_usuarios/media/media">
Require all granted
</Directory>

LoadFile "C:/Python311/python311.dll"
LoadModule wsgi_module "C:/Apache24/htdocs/Cadastro/env/Lib/site-packages/mod_wsgi-4.9.5.dev1-py3.11-win-amd64.egg/mod_wsgi/server/mod_wsgi.cp311-win_amd64.pyd"
WSGIPythonHome "C:/Apache24/htdocs/Cadastro/env"
WSGIScriptAlias / "C:/Apache24/htdocs/Cadastro/projeto_cad_usuarios/projeto_cad_usuarios/wsgi.py"
# WSGIPythonPath / "C:/Apache24/htdocs/Cadastro/projeto_cad_usuarios/projeto_cad_usuarios/"

<Directory "C:/Apache24/htdocs/Cadastro/projeto_cad_usuarios/projeto_cad_usuarios">
<Files wsgi.py>
Require all granted
</Files>
</Directory>

Show this message on the browser:

Internal Server Error
The server encountered an internal error or misconfiguration and was unable to complete your request.

Please contact the server administrator at admin@example.com to inform them of the time this error occurred, and the actions you performed just before this error.

More information about this error may be available in the server error log.

I don't know where else to go, I'm using ApacheLounge after reading your recommendation in another post.

@GrahamDumpleton
Copy link
Owner

At a guess you should have:

WSGIPythonPath / "C:/Apache24/htdocs/Cadastro/projeto_cad_usuarios"

You had it pointing at the wrong directory.

It should point to the parent directory of where your project is, not the project directory itself.

@PantaneiroCG
Copy link
Author

Graham, Thank you for your help and attention.
I did as per your guidance, however, now it presents this error when starting Apache: AH00526: Syntax error on line 557 of C:/Apache24/conf/httpd.conf:
WSGIPythonPath takes one argument, Python module search path.

New httpd.conf

Alias /robots.txt "C:/Apache24/htdocs/Cadastro/projeto_cad_usuarios/static/robots.txt"
Alias /favicon.ico "C:/Apache24/htdocs/Cadastro/projeto_cad_usuarios/static/favicon.ico"

Alias /media/ "C:/Apache24/htdocs/Cadastro/projeto_cad_usuarios/media/media"
Alias /static/ "C:/Apache24/htdocs/Cadastro/projeto_cad_usuarios/static"

<Directory "C:/Apache24/htdocs/Cadastro/projeto_cad_usuarios/static">
Require all granted

<Directory "C:/Apache24/htdocs/Cadastro/projeto_cad_usuarios/media/media">
Require all granted

LoadFile "C:/Python311/python311.dll"
LoadModule wsgi_module "C:/Apache24/htdocs/Cadastro/env/Lib/site-packages/mod_wsgi-4.9.5.dev1-py3.11-win-amd64.egg/mod_wsgi/server/mod_wsgi.cp311-win_amd64.pyd"
WSGIPythonHome "C:/Apache24/htdocs/Cadastro/env"
WSGIScriptAlias / "C:/Apache24/htdocs/Cadastro/projeto_cad_usuarios/projeto_cad_usuarios/wsgi.py"
WSGIPythonPath / "C:/Apache24/htdocs/Cadastro/projeto_cad_usuarios"

<Directory "C:/Apache24/htdocs/Cadastro/projeto_cad_usuarios/projeto_cad_usuarios">

Require all granted

@GrahamDumpleton
Copy link
Owner

My mistake, I just copied what you had, which was in part wrong to start with ignoring the path issue.

Use:

WSGIPythonPath "C:/Apache24/htdocs/Cadastro/projeto_cad_usuarios"

It should only be given one argument.

@PantaneiroCG
Copy link
Author

Okay, I commented out the line as below, then it returns to the previous error. Apache manages to start, but when trying to access the application through the browser, it presents the errors as in the log above and does not load the application.

WSGIPythonPath / "C:/Apache24/htdocs/Cadastro/projeto_cad_usuarios"

@PantaneiroCG
Copy link
Author

I believe it's something I'm doing wrong in the httpd.conf configuration.

@GrahamDumpleton
Copy link
Owner

At the very start of the wsgi.py file, before any imports, add:

import sys
print(sys.path)

What is the value for sys.path that is printed out into the logs?

@PantaneiroCG
Copy link
Author

It was the first lines of the log and errors:
[Mon Jul 03 20:17:05.036983 2023] [mpm_winnt:notice] [pid 11860:tid 512] AH00455: Apache/2.4.57 (Win64) mod_wsgi/4.9.5.dev1 Python/3.11 configured -- resuming normal operations
[Mon Jul 03 20:17:05.036983 2023] [mpm_winnt:notice] [pid 11860:tid 512] AH00456: Apache Lounge VS17 Server built: May 31 2023 10:48:22
[Mon Jul 03 20:17:05.036983 2023] [core:notice] [pid 11860:tid 512] AH00094: Command line: 'httpd -d C:/Apache24'
[Mon Jul 03 20:17:05.052589 2023] [mpm_winnt:notice] [pid 11860:tid 512] AH00418: Parent: Created child process 8440
[Mon Jul 03 20:17:05.413248 2023] [mpm_winnt:notice] [pid 8440:tid 512] AH00354: Child: Starting 64 worker threads.

@GrahamDumpleton
Copy link
Owner

You need to make a request to the WSGI application else you will not see the message as the wsgi.py file will only be loaded when first request arrives. You may need to restart the Apache service as well if how things are setup means the wsgi.py has been cached in memory.

@PantaneiroCG
Copy link
Author

With these httpd.conf settings, is this request not being made to the wsgi application?
How to make this request correctly?

@GrahamDumpleton
Copy link
Owner

Using your web browser go to the same URL you have been using to try and access the application. The output of any print() statements in the wsgi.py should be displayed in the Apache error log if things are set correctly in the Apache config.

So did you try and access your web site or not?

Also ensure that LogLevel is set to info and not err or warn so can see when mod_wsgi loads the wsgi.py. That will confirm you actually made a request and it was received properly.

@PantaneiroCG
Copy link
Author

Ahh yes, now I understand, I'm sorry that English is not my official language in my country.
I'm going to configure Apache to show this message, I tried to access the application through the browser, but the messages that appeared in the log were those.
Please, do not close this post, as I lost connection to the server I was accessing remotely and as soon as I resume I will continue my saga.. :-) And I will return with the result of the message as soon as possible.

@PantaneiroCG
Copy link
Author

Graham, thank you for your patience, I changed the apache configuration to info and new lines appeared in the log:

[Tue Jul 04 08:41:24.304642 2023] [wsgi:info] [pid 5348:tid 1248] [client 10.32.2.250:58795] mod_wsgi (pid=5348, process='', application='localhost:81|'): Loading Python script file 'C:/Apache24/htdocs/Cadastro/projeto_cad_usuarios/projeto_cad_usuarios/wsgi.py'.
[Tue Jul 04 08:41:24.309629 2023] [wsgi:error] [pid 5348:tid 1248] [client 10.32.2.250:58795] mod_wsgi (pid=5348): Failed to exec Python script file 'C:/Apache24/htdocs/Cadastro/projeto_cad_usuarios/projeto_cad_usuarios/wsgi.py'.
[Tue Jul 04 08:41:24.309629 2023] [wsgi:error] [pid 5348:tid 1248] [client 10.32.2.250:58795] mod_wsgi (pid=5348): Exception occurred processing WSGI script 'C:/Apache24/htdocs/Cadastro/projeto_cad_usuarios/projeto_cad_usuarios/wsgi.py'.
[Tue Jul 04 08:41:24.310625 2023] [wsgi:error] [pid 5348:tid 1248] [client 10.32.2.250:58795] Traceback (most recent call last):\r
[Tue Jul 04 08:41:24.310625 2023] [wsgi:error] [pid 5348:tid 1248] [client 10.32.2.250:58795] File "C:/Apache24/htdocs/Cadastro/projeto_cad_usuarios/projeto_cad_usuarios/wsgi.py", line 16, in \r
[Tue Jul 04 08:41:24.310625 2023] [wsgi:error] [pid 5348:tid 1248] [client 10.32.2.250:58795] application = get_wsgi_application()\r
[Tue Jul 04 08:41:24.310625 2023] [wsgi:error] [pid 5348:tid 1248] [client 10.32.2.250:58795] ^^^^^^^^^^^^^^^^^^^^^^\r
[Tue Jul 04 08:41:24.310625 2023] [wsgi:error] [pid 5348:tid 1248] [client 10.32.2.250:58795] File "C:\Apache24\htdocs\Cadastro\env\Lib\site-packages\django\core\wsgi.py", line 12, in get_wsgi_application\r
[Tue Jul 04 08:41:24.310625 2023] [wsgi:error] [pid 5348:tid 1248] [client 10.32.2.250:58795] django.setup(set_prefix=False)\r
[Tue Jul 04 08:41:24.310625 2023] [wsgi:error] [pid 5348:tid 1248] [client 10.32.2.250:58795] File "C:\Apache24\htdocs\Cadastro\env\Lib\site-packages\django\init.py", line 19, in setup\r
[Tue Jul 04 08:41:24.310625 2023] [wsgi:error] [pid 5348:tid 1248] [client 10.32.2.250:58795] configure_logging(settings.LOGGING_CONFIG, settings.LOGGING)\r
[Tue Jul 04 08:41:24.310625 2023] [wsgi:error] [pid 5348:tid 1248] [client 10.32.2.250:58795] ^^^^^^^^^^^^^^^^^^^^^^^\r
[Tue Jul 04 08:41:24.310625 2023] [wsgi:error] [pid 5348:tid 1248] [client 10.32.2.250:58795] File "C:\Apache24\htdocs\Cadastro\env\Lib\site-packages\django\conf\init.py", line 57, in getattr\r
[Tue Jul 04 08:41:24.310625 2023] [wsgi:error] [pid 5348:tid 1248] [client 10.32.2.250:58795] self._setup(name)\r
[Tue Jul 04 08:41:24.310625 2023] [wsgi:error] [pid 5348:tid 1248] [client 10.32.2.250:58795] File "C:\Apache24\htdocs\Cadastro\env\Lib\site-packages\django\conf\init.py", line 44, in _setup\r
[Tue Jul 04 08:41:24.310625 2023] [wsgi:error] [pid 5348:tid 1248] [client 10.32.2.250:58795] self._wrapped = Settings(settings_module)\r
[Tue Jul 04 08:41:24.310625 2023] [wsgi:error] [pid 5348:tid 1248] [client 10.32.2.250:58795] ^^^^^^^^^^^^^^^^^^^^^^^^^\r
[Tue Jul 04 08:41:24.311623 2023] [wsgi:error] [pid 5348:tid 1248] [client 10.32.2.250:58795] File "C:\Apache24\htdocs\Cadastro\env\Lib\site-packages\django\conf\init.py", line 107, in init\r
[Tue Jul 04 08:41:24.311623 2023] [wsgi:error] [pid 5348:tid 1248] [client 10.32.2.250:58795] mod = importlib.import_module(self.SETTINGS_MODULE)\r
[Tue Jul 04 08:41:24.311623 2023] [wsgi:error] [pid 5348:tid 1248] [client 10.32.2.250:58795] ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^\r
[Tue Jul 04 08:41:24.311623 2023] [wsgi:error] [pid 5348:tid 1248] [client 10.32.2.250:58795] File "C:\Python311\Lib\importlib\init.py", line 126, in import_module\r
[Tue Jul 04 08:41:24.311623 2023] [wsgi:error] [pid 5348:tid 1248] [client 10.32.2.250:58795] return _bootstrap._gcd_import(name[level:], package, level)\r
[Tue Jul 04 08:41:24.311623 2023] [wsgi:error] [pid 5348:tid 1248] [client 10.32.2.250:58795] ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^\r
[Tue Jul 04 08:41:24.311623 2023] [wsgi:error] [pid 5348:tid 1248] [client 10.32.2.250:58795] File "", line 1206, in _gcd_import\r
[Tue Jul 04 08:41:24.311623 2023] [wsgi:error] [pid 5348:tid 1248] [client 10.32.2.250:58795] File "", line 1178, in _find_and_load\r
[Tue Jul 04 08:41:24.311623 2023] [wsgi:error] [pid 5348:tid 1248] [client 10.32.2.250:58795] File "", line 1128, in _find_and_load_unlocked\r
[Tue Jul 04 08:41:24.311623 2023] [wsgi:error] [pid 5348:tid 1248] [client 10.32.2.250:58795] File "", line 241, in _call_with_frames_removed\r
[Tue Jul 04 08:41:24.311623 2023] [wsgi:error] [pid 5348:tid 1248] [client 10.32.2.250:58795] File "", line 1206, in _gcd_import\r
[Tue Jul 04 08:41:24.311623 2023] [wsgi:error] [pid 5348:tid 1248] [client 10.32.2.250:58795] File "", line 1178, in _find_and_load\r
[Tue Jul 04 08:41:24.311623 2023] [wsgi:error] [pid 5348:tid 1248] [client 10.32.2.250:58795] File "", line 1142, in _find_and_load_unlocked\r
[Tue Jul 04 08:41:24.311623 2023] [wsgi:error] [pid 5348:tid 1248] [client 10.32.2.250:58795] ModuleNotFoundError: No module named 'projeto_cad_usuarios'\r

@PantaneiroCG
Copy link
Author

Graham, performing the tests I added the root folder in the line: "WSGIScriptAlias ​​/projeto_cad_usuarios "C:/Apache24/htdocs/Cadastro/projeto_cad_usuarios/projeto_cad_usuarios/wsgi.py" after the slash.
As a result the lines below and in the browser only my project folders and files without rendering the application.

[Tue Jul 04 10:10:36.489918 2023] [mpm_winnt:notice] [pid 12816:tid 540] AH00455: Apache/2.4.57 (Win64) mod_wsgi/4.9.5.dev1 Python/3.11 configured -- resuming normal operations
[Tue Jul 04 10:10:36.489918 2023] [mpm_winnt:notice] [pid 12816:tid 540] AH00456: Apache Lounge VS17 Server built: May 31 2023 10:48:22
[Tue Jul 04 10:10:36.489918 2023] [core:notice] [pid 12816:tid 540] AH00094: Command line: 'httpd -d C:/Apache24'
[Tue Jul 04 10:10:36.489918 2023] [mpm_winnt:notice] [pid 12816:tid 540] AH00418: Parent: Created child process 5932
[Tue Jul 04 10:10:36.755479 2023] [wsgi:info] [pid 5932:tid 512] mod_wsgi (pid=5932): Initializing Python.
[Tue Jul 04 10:10:36.771101 2023] [wsgi:info] [pid 5932:tid 512] mod_wsgi (pid=5932): Attach interpreter ''.
[Tue Jul 04 10:10:36.771101 2023] [wsgi:info] [pid 5932:tid 512] mod_wsgi (pid=5932): Adding 'C:/Apache24/htdocs/Cadastro/env/Lib/site-packages' to path.
[Tue Jul 04 10:10:36.786719 2023] [wsgi:info] [pid 5932:tid 512] mod_wsgi (pid=5932): Imported 'mod_wsgi'.
[Tue Jul 04 10:10:36.802342 2023] [mpm_winnt:notice] [pid 5932:tid 512] AH00354: Child: Starting 64 worker threads.

When I stop apache:

[Tue Jul 04 10:21:36.901895 2023] [mpm_winnt:notice] [pid 12816:tid 540] AH00422: Parent: Received shutdown signal -- Shutting down the server.
Apache server interrupted...
Apache server interrupted...
[Tue Jul 04 10:21:38.904605 2023] [mpm_winnt:notice] [pid 5932:tid 512] AH00364: Child: All worker threads have exited.
[Tue Jul 04 10:21:38.904605 2023] [wsgi:info] [pid 5932:tid 512] mod_wsgi (pid=5932): Destroying interpreters.
[Tue Jul 04 10:21:38.904605 2023] [wsgi:info] [pid 5932:tid 512] mod_wsgi (pid=5932): Cleanup interpreter ''.
[Tue Jul 04 10:21:38.904605 2023] [wsgi:info] [pid 5932:tid 512] mod_wsgi (pid=5932): Terminating Python.
[Tue Jul 04 10:21:38.919543 2023] [wsgi:info] [pid 5932:tid 512] mod_wsgi (pid=5932): Python has shutdown.
[Tue Jul 04 10:21:38.944652 2023] [mpm_winnt:notice] [pid 12816:tid 540] AH00430: Parent: Child process 5932 exited successfully.
[Tue Jul 04 10:21:38.945649 2023] [core:info] [pid 12816:tid 540] AH00096: removed PID file C:/Apache24/logs/httpd.pid (pid=12816)

@GrahamDumpleton
Copy link
Owner

Those last of logs with the exception traceback do not show any output that I can see corresponding to the lines:

import sys
print(sys.path)

which I told you to add. Were they added?

To make it more obvious, change it to:

import sys
print("PATH:", sys.path)

Ensure these two lines are the very first lines in the wsgi.py file.

@PantaneiroCG
Copy link
Author

My file wsgi.py

import os
import sys

print("PATH:", sys.path)

from django.core.wsgi import get_wsgi_application

os.environ.setdefault('DJANGO_SETTINGS_MODULE', 'projeto_cad_usuarios.settings')
application = get_wsgi_application()

I did before and now again. Below I am also sending new log:

access:

10.32.2.250 - - [06/Jul/2023:08:48:14 -0400] "GET /Cadastro/ HTTP/1.1" 200 322

error:

[Thu Jul 06 08:48:06.739594 2023] [mpm_winnt:notice] [pid 8536:tid 584] AH00455: Apache/2.4.57 (Win64) mod_wsgi/4.9.5.dev1 Python/3.11 configured -- resuming normal operations
[Thu Jul 06 08:48:06.739594 2023] [mpm_winnt:notice] [pid 8536:tid 584] AH00456: Apache Lounge VS17 Server built: May 31 2023 10:48:22
[Thu Jul 06 08:48:06.739594 2023] [core:notice] [pid 8536:tid 584] AH00094: Command line: 'httpd -d C:/Apache24'
[Thu Jul 06 08:48:06.739594 2023] [mpm_winnt:notice] [pid 8536:tid 584] AH00418: Parent: Created child process 10564
[Thu Jul 06 08:48:07.020787 2023] [wsgi:info] [pid 10564:tid 512] mod_wsgi (pid=10564): Initializing Python.
[Thu Jul 06 08:48:07.036406 2023] [wsgi:info] [pid 10564:tid 512] mod_wsgi (pid=10564): Attach interpreter ''.
[Thu Jul 06 08:48:07.052028 2023] [wsgi:info] [pid 10564:tid 512] mod_wsgi (pid=10564): Adding 'C:/Apache24/htdocs/Cadastro/env/Lib/site-packages' to path.
[Thu Jul 06 08:48:07.067621 2023] [wsgi:info] [pid 10564:tid 512] mod_wsgi (pid=10564): Imported 'mod_wsgi'.
[Thu Jul 06 08:48:07.067621 2023] [mpm_winnt:notice] [pid 10564:tid 512] AH00354: Child: Starting 64 worker threads.

There really wasn't anything corresponding to the ptint. I remember that when it was still giving an error, I did a test and a print appeared in the log, but with an error status:

[Tue Jul 04 09:02:45.626529 2023] [wsgi:error] [pid 5348:tid 1248] teste*****\r**
[Tue Jul 04 09:02:45.629520 2023] [wsgi:error] [pid 5348:tid 1248] [client 10.32.2.250:58928] mod_wsgi (pid=5348): Failed to exec Python script file 'C:/Apache24/htdocs/Cadastro/projeto_cad_usuarios/projeto_cad_usuarios/wsgi.py'.
[Tue Jul 04 09:02:45.629520 2023] [wsgi:error] [pid 5348:tid 1248] [client 10.32.2.250:58928] mod_wsgi (pid=5348): Exception occurred processing WSGI script 'C:/Apache24/htdocs/Cadastro/projeto_cad_usuarios/projeto_cad_usuarios/wsgi.py'.

@PantaneiroCG
Copy link
Author

Hi Graham.
I noticed that when I run the python development server, the result of the wsgi.py print command appears.

(env) C:\Apache24\htdocs\Cadastro\projeto_cad_usuarios>python manage.py runserver
Performing system checks...

System check identified no issues (0 silenced).
July 06, 2023 - 15:00:44
Django version 2.1.15, using settings 'projeto_cad_usuarios.settings'
Starting development server at http://127.0.0.1:8000/
Quit the server with CTRL-BREAK.
PATH: ['C:\\Apache24\\htdocs\\Cadastro\\projeto_cad_usuarios', 'C:\\Python311\\python311.zip', 'C:\\Python311\\DLLs', 'C:\\Python311\\Lib', 'C:\\Python311', 'C:\\Apache24\\htdocs\\Cadastro\\env', 'C:\\Apache24\\htdocs\\Cadastro\\env\\Lib\\site-packages', 'C:\\Apache24\\htdocs\\Cadastro\\env\\Lib\\site-packages\\mod_wsgi-4.9.5.dev1-py3.11-win-amd64.egg', 'C:\\Apache24\\htdocs\\Cadastro\\env\\Lib\\site-packages\\win32', 'C:\\Apache24\\htdocs\\Cadastro\\env\\Lib\\site-packages\\win32\\lib', 'C:\\Apache24\\htdocs\\Cadastro\\env\\Lib\\site-packages\\Pythonwin']
test.. test**********************

@GrahamDumpleton
Copy link
Owner

Did you ever sort this out? I have been travelling and so lots of stuff got neglected. Now only back and trying to catch up.

@PantaneiroCG
Copy link
Author

No solution for this problem so far.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants