Python Anywhere cannot find module

Viewed 95

I cannot seem to Import From x import y a module in a subdirectory in Python Anywhere.

My app structure is as follows:

Home path:

app.py
Index.py

apps path - a subdirectory contained within my Home directory:

__init__.py (Blank init file)
Visualize.py

in my Index.py file I am attempting:

from apps import Visualize.py

I am getting a syntax error,

I have then changed it to test:

from . import apps

and it accepts this but I cannot reach my Visualize.py - any ideas why?

Further information on my wsgi.py - Directory and start:

# add your project directory to the sys.path
project_home = '/home/UserName/UserApp/'
if project_home not in sys.path:
    sys.path = [project_home] + sys.path

# import flask app but need to call it "application" for WSGI to work
from Index import app
application = app.server
1 Answers

from apps import Visualize.py is not how you import from a file called Visualize.py. You would need to use from apps.Visualize import something Also, with your wsgi file, the apps directory would need to be in /home/UserName/UserApp/

Related