#1 check if you have an OLD python installation and remove it properly (including old environment vars, path ..)
#2 i would recommend you, if possible, upgrading your python installation to the last one 3.8.x +
#3 your problem is very common: your environment variables are NOT correctly set:
- go to Advancedtab underSystem Propertiesand clickEnvironment Variables
- Under System Variablescreate those variables:
- APACHE_HOME= C:\wamp\bin\apache\apache2.4.23 (i'm using- WAMPSERVER)
- MOD_WSGI_APACHE_ROOTDIR=- %APACHE_HOME%(since you are using- mod_wsgi, check official doc on- pypi)
- PYTHON_HOME= C:\Python37 (it depends on your python installation)
 
- go to User variablesand add/append variables toPATHlike so:
- PATH=- %APACHE_HOME%\bin;%MOD_WSGI_APACHE_ROOTDIR%;%PYTHON_HOME%;%PYTHON_HOME%\Scripts;
 
#4 open new console and check your python installation:
#5 create a simple flask app to make sure everything is working as expected
#6 to deploy the app on Apache server, have look at this flask doc and the official mod_wsgi doc
- you have to install mod_wsgiGLOBALLY, meaning you have to deactivate first your virtual environment of your current active application.
- (venv) C:\myapps\flask\helloflask>deactivate(i'm using- venvthe standard and default python virtual environment- py -m venv venv)
- C:\myapps\flask\helloflask>pip install mod_wsgi
- C:\myapps\flask\helloflask>pip list
#7 configure mod_wsgi in Apache Server
- check if mod_wsgiis correctly installed and configured
C:\myapps\flask\helloflask>mod_wsgi-express --help
Usage: mod_wsgi-express command [params]
Commands:
    module-config
    module-location
mod_wsgi-express: error: Invalid command was specified.
mod_wsgi-express module-config
- the output of the command should be like the following (depending on your system and python installation):
    WSGIPythonHome "c:/python37"
    LoadFile "c:/python37/python37.dll"
    loadmodule wsgi_module "c:/python37/lib/site-packages/mod_wsgi/server/mod_wsgi.cp37-win32.pyd"
- Copy the output of the above command and paste it in  C:\wamp\bin\apache\apache2.4.23\conf. To make things consistent, locate the section where Modules are listed and add it at the very end of the list.
#8 create wsgi.py under the root of your project and paste the code (it's self-explanatory)
import os
import sys
# activate virtualenv
PROJECT = "helloflask"
# i'm using py -m venv venv
# @see: https://modwsgi.readthedocs.io/en/develop/user-guides/virtual-environments.html
# @see: https://stackoverflow.com/questions/25020451/no-activate-this-py-file-in-venv-pyvenv
activate_this = os.path.join('C:/myapps/flask', PROJECT, 'venv/Scripts/activate_this.py')
with open(activate_this) as file_:
    exec(file_.read(), dict(__file__=activate_this))
BASE_DIR = os.path.join(os.path.dirname(__file__))
if BASE_DIR not in sys.path:
    sys.path.append(BASE_DIR)
from helloflask import create_app
application = create_app() 
#9 Configure a Virtual Host for the Flask App
<VirtualHost *:80>
    ServerName helloflask.local
    DocumentRoot "C:/myapps/flask/helloflask"
    WSGIScriptAlias / "C:/myapps/flask/helloflask/wsgi.py"
    <Directory "C:/myapps/flask/helloflask">
        Require all granted
    </Directory>
    # app = Flask(
    #    __name__, 
    #    static_url_path='/public/static',
    #    static_folder='static'
    # )
    # Alias /public/static  "C:/myapps/flask/helloflask/public/static"
    # <Directory "C:/myapps/flask/helloflask/public/static">
    #    Require all granted
    # </Directory>
    
    ErrorLog "C:/wamp/logs/helloflask.error.log"
    CustomLog "C:/wamp/logs/helloflask.access.log" common
</VirtualHost>
#10 check your Apache configuration
- httpd -tif it's OK, restart your- Apacheserver