在PythonAnywhere中分发DjangoProject时发生错误-ModuleNotFoundError:没有名为“ mysite”的模块

时间:2020-09-21 02:24:49

标签: python django pythonanywhere

发行版/ pythonanywhere,django_project /中存在错误 我查找了所有相关的Stack Overflow文章!但是我没有解决这个问题 请让我知道请让我知道请让我知道请让我知道请让我知道

2020-09-21 02:01:37,406: Error running WSGI application
2020-09-21 02:01:37,407: ModuleNotFoundError: No module named 'mysite'
2020-09-21 02:01:37,407:   File "/var/www/emoclew_pythonanywhere_com_wsgi.py", line 12, in <module>
2020-09-21 02:01:37,407:     application = StaticFilesHandler(get_wsgi_application())
2020-09-21 02:01:37,407: 
2020-09-21 02:01:37,407:   File "/home/emoclew/covid19_survey/myvenv/lib/python3.8/site-packages/django/core/wsgi.py", line 12, in get_wsgi_application
2020-09-21 02:01:37,407:     django.setup(set_prefix=False)
2020-09-21 02:01:37,408: 
2020-09-21 02:01:37,408:   File "/home/emoclew/covid19_survey/myvenv/lib/python3.8/site-packages/django/__init__.py", line 19, in setup
2020-09-21 02:01:37,408:     configure_logging(settings.LOGGING_CONFIG, settings.LOGGING)
2020-09-21 02:01:37,408: 
2020-09-21 02:01:37,408:   File "/home/emoclew/covid19_survey/myvenv/lib/python3.8/site-packages/django/conf/__init__.py", line 83, in __getattr__
2020-09-21 02:01:37,408:     self._setup(name)
2020-09-21 02:01:37,409: 
2020-09-21 02:01:37,409:   File "/home/emoclew/covid19_survey/myvenv/lib/python3.8/site-packages/django/conf/__init__.py", line 70, in _setup
2020-09-21 02:01:37,409:     self._wrapped = Settings(settings_module)
2020-09-21 02:01:37,409: 
2020-09-21 02:01:37,409:   File "/home/emoclew/covid19_survey/myvenv/lib/python3.8/site-packages/django/conf/__init__.py", line 177, in __init__
2020-09-21 02:01:37,409:     mod = importlib.import_module(self.SETTINGS_MODULE)

这是我的项目树

(myvenv) 02:06 ~/covid19_survey (master)$ tree 
.
├── db.sqlite3
├── firstProject
│   ├── __init__.py
│   ├── __pycache__
│   │   ├── __init__.cpython-38.pyc
│   │   ├── settings.cpython-38.pyc
│   │   ├── urls.cpython-38.pyc
│   │   └── wsgi.cpython-38.pyc
│   ├── asgi.py
│   ├── settings.py
│   ├── urls.py
│   └── wsgi.py
├── ido
│   ├── __init__.py
│   ├── __pycache__
│   │   ├── __init__.cpython-38.pyc
│   │   ├── admin.cpython-38.pyc
│   │   ├── apps.cpython-38.pyc
│   │   ├── models.cpython-38.pyc
│   │   └── views.cpython-38.pyc
│   ├── admin.py
│   ├── apps.py
│   ├── migrations
│   │   ├── 0001_initial.py
│   │   ├── 0002_auto_20200915_1405.py
│   │   ├── 0003_auto_20200915_1408.py
│   │   ├── 0004_auto_20200915_1417.py
│   │   ├── 0005_auto_20200916_1030.py
│   │   ├── __init__.py
│   │   └── __pycache__
│   │       ├── 0001_initial.cpython-38.pyc
│   │       ├── 0002_auto_20200915_1405.cpython-38.pyc
│   │       ├── 0003_auto_20200915_1408.cpython-38.pyc
│   │       ├── 0004_auto_20200915_1417.cpython-38.pyc
│   │       ├── 0005_auto_20200916_1030.cpython-38.pyc
│   │       └── __init__.cpython-38.pyc
│   ├── models.py
│   ├── templates
│   │   ├── home.html
│   │   └── new.html
│   ├── tests.py
│   └── views.py
├── manage.py
├── myvenv
│   ├── bin
│   │   ├── __pycache__
│   │   │   └── django-admin.cpython-38.pyc
│   │   ├── activate
│   │   ├── activate.csh
│   │   ├── activate.fish
│   │   ├── activate.ps1
│   │   ├── activate.xsh
│   │   ├── activate_this.py
│   │   ├── chardetect
│   │   ├── django-admin
│   │   ├── django-admin.py
│   │   ├── dotenv
│   │   ├── easy_install
│   │   ├── easy_install-3.8
│   │   ├── pip
│   │   ├── pip3
│   │   ├── pip3.8
│   │   ├── pyjwt
│   │   ├── python -> python3.8
│   │   ├── python-config
│   │   ├── python3 -> python3.8
│   │   ├── python3.8
│   │   ├── sqlformat
│   │   └── wheel
│   ├── include
│   │   └── python3.8 -> /usr/include/python3.8
│   └── lib
│       └── python3.8

是 /var/www/emoclew_pythonanywhere_com_wsgi.py

import os
import sys

path = '/home/emoclew/covid19_survey'  
if path not in sys.path:
    sys.path.append(path)

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

from django.core.wsgi import get_wsgi_application
from django.contrib.staticfiles.handlers import StaticFilesHandler
application = StaticFilesHandler(get_wsgi_application())

0 个答案:

没有答案