热门标签:
Q:

运行WSGI应用程序时出错,ModuleNotFoundError:No module named'mysite'

我试图通过使用pythonanywhere的项目部署我的Django项目,但我遇到了一个问题,并且真的被卡住了。 任何人都可以帮助我。 附在我的路径上的图像setting.py 档案。 路径到settings.py

该WSGI.py Webttab上的配置是:

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()

和错误显示后,我重新加载是:

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)

我该怎么办?

先谢谢你。

原网址
A:

你的路径需要是/home/technewsandblog/blog/blog_project

目前,您的路径/home/technewsandblog/blog/blog_project/mysite和设置模块mysite.settings意味着它期待一个settings.py 文件在/home/technewsandblog/blog/blog_project/mysite/mysite/settings.py

还可以查看WSGI import errors上的PythonAnywhere帮助页面。 (特别是Django部分)

相似问题