Forums

Problems with deploying

import os import sys

path = '/home/alvinzhan/alvin_website' if path not in sys.path: sys.path.append(path)

os.environ['DJANGO_SETTINGS_MODULE'] = 'alvin_website.settings'

from django.core.wsgi import get_wsgi_application application = get_wsgi_application()


Sorry, I'm quite sure that I have type the correct path and directotries, but I still get ModuleNotFoundError: No module named 'alvin_website.settings' in the error.log. Can anybody help me please!!!!

My python version is 3.6 and Django is 2.0.

Have a look at our help page for debugging that sort of thing: http://help.pythonanywhere.com/pages/DebuggingImportError/

Sorry, I have looked the help page before and I can run the files in my virtualenv.

I still cannot deploy my website successfully, still got ModuleNotFoundError.

Maybe you have an aliasing issue - in your wsgi file, just after you have set up sys.path, add this:

import alvin_website
print(alvin_website.__file__, file=sys.stderr)

and look in your error log to see what is being printed. Make sure it's the directory that your settings.py is in.

um.... I have add the two statement in my wsgi.py, but the error log also shows the same error.

and I try to run it in my virtualenv it shows this path: /home/alvinzhan/alvin_website/alvin_website/init.py is this right?

my settings.py is in /home/alvinzhan/alvin_website/alvin_website/

Thank you.

I see a line printed in your server.log.

It seems that alvin_website.__file__ is ./alvin_website/init.py. What happens if you print the full path instead of relative path?

Sorry, I don't understand what you mean. What is the full path?

Oops i meant os.path.abspath

I add this statement print(os.path.abspath(os.path.dirname(file))) and it shows the path: /var/www

Is this correct?

wait- did you do alvin_website.__file__ or just __file__

just __file__ and the error log shows exactly the same.

ok- can you see what alvin_website.__file__ is, not just __file__?

The error log shows this: NameError: name 'alvin_website' is not defined.

did you try to print this before your import?