mod_wsgi icon indicating copy to clipboard operation
mod_wsgi copied to clipboard

I am on windows, the problem is with my virtual environment. Respectfully, I want to understand where is the activate_this.py file?

Open Chinmay2709 opened this issue 2 years ago • 2 comments

It's been days now, and after resolving an array of errors, I guess or should I say, I wish, I am on my final error for my flask deployment on apache servers. Respectfully, I am curious to understand where is the activate_this.py in my virtual environment that I can use to tell my .wsgi script to execute. As, my app folder structure has only activate file under script, and similar versions for .bat .ps1. Would you be please! please! please! kind enough to tell me where am I going wrong with this, and what am I required to do. As, I suppose you would understand how frustrated I had become to actually go through all these errors, which are haulting my progress. Thank you.

Here is my .wsgi script: `#!

import sys

activate_this = "C:/xampp/htdocs/ForEx/Scripts/activate" with open(activate_this) as file_: exec(file_.read(),dict(file=activate_this))

sys.path.insert(0,'C:\xampp\htdocs\ForEx\') from app import app as application

`

Here is my error log: ' [Sat Feb 11 00:46:42.640691 2023] [wsgi:error] [pid 5580:tid 1972] [client 127.0.0.1:60369] mod_wsgi (pid=5580): Failed to exec Python script file 'C:/xampp/htdocs/ForEx/web.wsgi'., referer: http://127.0.0.1/ [Sat Feb 11 00:46:42.640691 2023] [wsgi:error] [pid 5580:tid 1972] [client 127.0.0.1:60369] mod_wsgi (pid=5580): Exception occurred processing WSGI script 'C:/xampp/htdocs/ForEx/web.wsgi'., referer: http://127.0.0.1/ [Sat Feb 11 00:46:42.640691 2023] [wsgi:error] [pid 5580:tid 1972] [client 127.0.0.1:60369] Traceback (most recent call last):\r, referer: http://127.0.0.1/ [Sat Feb 11 00:46:42.640691 2023] [wsgi:error] [pid 5580:tid 1972] [client 127.0.0.1:60369] File "C:/xampp/htdocs/ForEx/web.wsgi", line 8, in \r, referer: http://127.0.0.1/ [Sat Feb 11 00:46:42.640691 2023] [wsgi:error] [pid 5580:tid 1972] [client 127.0.0.1:60369] exec(file_.read(),dict(file=activate_this))\r, referer: http://127.0.0.1/ [Sat Feb 11 00:46:42.640691 2023] [wsgi:error] [pid 5580:tid 1972] [client 127.0.0.1:60369] File "", line 4\r, referer: http://127.0.0.1/ [Sat Feb 11 00:46:42.640691 2023] [wsgi:error] [pid 5580:tid 1972] [client 127.0.0.1:60369] deactivate () {\r, referer: http://127.0.0.1/ [Sat Feb 11 00:46:42.640691 2023] [wsgi:error] [pid 5580:tid 1972] [client 127.0.0.1:60369] ^\r, referer: http://127.0.0.1/ [Sat Feb 11 00:46:42.640691 2023] [wsgi:error] [pid 5580:tid 1972] [client 127.0.0.1:60369] SyntaxError: invalid syntax\r, referer: http://127.0.0.1/

'

Chinmay2709 avatar Feb 11 '23 05:02 Chinmay2709

When activating virtual environment manually, you usually type such a command in your command prompt: .\envname\Scripts\activate

The activate_this.py refers to that script that is being executed through this command.

refer to this

Hilthertoidk avatar Mar 12 '23 17:03 Hilthertoidk

Hmmm, seems I never got notification on the original issue creation. Either way, avoid using activate_this.py. See:

  • https://modwsgi.readthedocs.io/en/master/user-guides/virtual-environments.html

on recommended ways to use a virtual environment.

GrahamDumpleton avatar Mar 12 '23 20:03 GrahamDumpleton