I am puzzled by no module named app importerror. When I use name FlaskApp, everything works, when I change name to xyzApp, it does not and I am getting ImportError.
Here is the error code:
Target WSGI script '/var/www/xyz/xyzApp.wsgi' cannot be loaded as Python module.
Exception occurred processing WSGI script '/var/www/xyz/xyzApp.wsgi'.
Traceback (most recent call last):
File "/var/www/xyz/xyzApp.wsgi", line 11, in <module>
from xyzApp import app as application
ImportError: No module named 'xyzApp'
Target WSGI script '/var/www/xyz/xyzApp.wsgi' cannot be loaded as Python module.
Exception occurred processing WSGI script '/var/www/xyz/xyzApp.wsgi'.
Traceback (most recent call last):
File "/var/www/xyz/xyzApp.wsgi", line 11, in <module>
from xyzApp import app as application
ImportError: No module named 'xyzApp'
The Structure of the Flask applications looks as follows:
/var/www/xyz/
|--xyzApp.wsgi
|--/instance/config.py
|--/xyzApp
|--/static
|--/templates
|--__init__.py
When I do application with similar structure but with FlaskApp folders, it works. Why is that? The structure that works is as follows:
/var/www/FlaskApp/
|--flaskapp.wsgi
|--/FlaskApp
|--/static
|--/templates
|--__init__.py
The content of flaskapp.wsgi file is the same except for xyzApp:
#! /usr/bin/python3
import sys
import logging
logging.basicConfig(stream=sys.stderr)
sys.path.insert(0,"/var/www/FlaskApp")
from FlaskApp import app as application