Error running WSGI application , ModuleNotFoundError: No module named 'mysite'

冷暖自知 提交于 2019-12-11 04:42:05

问题


I am trying to deploy my Django project through the project using pythonanywhere but I am getting a problem and am really stuck. Can anyone help me with that. The image attached to the path to my setting.py file. Path to settings.py .

The WSGI.py configuration on Webttab is:

path = '/home/technewsandblog/blog/blog_project/mysite'
if path not in sys.path:
sys.path.append(path)

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

# then:

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

And The Error shows after I reload is:

Error running WSGI application
2018-07-08 20:30:23,383: ModuleNotFoundError: No module named 'mysite'

2018-07-08 20:30:23,383:   File "/var/www/technewsandblog_pythonanywhere_com_wsgi.py", line 18, in <module>

2018-07-08 20:30:23,383:     application = get_wsgi_application()

2018-07-08 20:30:23,384: 
2018-07-08 20:30:23,384:   File "/home/technewsandblog/.virtualenvs/myDjangoEnv/lib/python3.6/site-packages/django/core/wsgi.py", line 12, in get_wsgi_application

2018-07-08 20:30:23,384:     django.setup(set_prefix=False)

2018-07-08 20:30:23,384: 
2018-07-08 20:30:23,384:   File "/home/technewsandblog/.virtualenvs/myDjangoEnv/lib/python3.6/site-packages/django/__init__.py", line 19, in setup

2018-07-08 20:30:23,384:     configure_logging(settings.LOGGING_CONFIG, settings.LOGGING)

2018-07-08 20:30:23,384: 
2018-07-08 20:30:23,385:   File "/home/technewsandblog/.virtualenvs/myDjangoEnv/lib/python3.6/site-packages/django/conf/__init__.py", line 56, in __getattr__
2018-07-08 20:30:23,385:     self._setup(name)

2018-07-08 20:30:23,385: 
2018-07-08 20:30:23,385:   File "/home/technewsandblog/.virtualenvs/myDjangoEnv/lib/python3.6/site-packages/django/conf/__init__.py", line 43, in _setup

2018-07-08 20:30:23,385:     self._wrapped = Settings(settings_module)

2018-07-08 20:30:23,385: 

2018-07-08 20:30:23,386:   File "/home/technewsandblog/.virtualenvs/myDjangoEnv/lib/python3.6/site-packages/django/conf/__init__.py", line 106, in __init__

2018-07-08 20:30:23,386:     mod = importlib.import_module(self.SETTINGS_MODULE)

What should I do?

Thanks in advance.


回答1:


Your path needs to be /home/technewsandblog/blog/blog_project.

Currently, your path of /home/technewsandblog/blog/blog_project/mysite and settings module mysite.settings means that it is expecting a settings.py file at /home/technewsandblog/blog/blog_project/mysite/mysite/settings.py

Also check out the PythonAnywhere help page on WSGI import errors. (in particular the Django section)



来源:https://stackoverflow.com/questions/51235954/error-running-wsgi-application-modulenotfounderror-no-module-named-mysite

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!