我在django中是个新手,正在项目的部署阶段。但是在完成所有设置后,它将显示500个内部服务器错误,并且apache2错误日志显示ImportError: No module named 'backend'
我试图编辑wsgi.py,因为这是导致此错误的原因
这是我的wsgi.py文件的内容
import os
from django.core.wsgi import get_wsgi_application
os.environ.setdefault('DJANGO_SETTINGS_MODULE', 'backend.settings.dev')
application = get_wsgi_application()
settings / dev.py
DEBUG = True
ALLOWED_HOSTS = ['my_ip_address']
WSGI_APPLICATION = 'backend.wsgi.application'
manage.py
import os
import sys
if __name__ == '__main__':
os.environ.setdefault('DJANGO_SETTINGS_MODULE', 'backend.settings.dev')
try:
from django.core.management import execute_from_command_line
except ImportError as exc:
raise ImportError(
"Couldn't import Django. Are you sure it's installed and "
"available on your PYTHONPATH environment variable? Did you "
"forget to activate a virtual environment?"
) from exc
execute_from_command_line(sys.argv)
目录结构:
atms
--backend
--wsgi.py
--urls.py
--settings
--dev.py
--manage.py
点冻结:
cairocffi==0.9.0
CairoSVG==2.2.1
cffi==1.11.5
cssselect2==0.2.1
defusedxml==0.5.0
Django==2.1.5
django-countries==5.3.2
django-weasyprint==0.5.4
djangorestframework==3.9.1
gunicorn==19.9.0
html5lib==1.0.1
Pillow==5.4.1
pycparser==2.19
Pyphen==0.9.5
pytz==2018.9
six==1.12.0
tinycss2==0.6.1
WeasyPrint==44
webencodings==0.5.1
whitenoise==4.0
/ p / apache2 / sites-avalible中的atms.conf
Alias /static /home/atms/atms/public/static
<Directory /home/atms/atms/public/static>
Require all granted
</Directory>
Alias /media /home/atms/atms/media
<Directory /home/atms/atms/media>
Require all granted
</Directory>
<Directory /home/atms/atms/backend>
<Files wsgi.py>
Require all granted
</Files>
</Directory>
WSGIScriptAlias / /home/atms/atms/backend/wsgi.py
WSGIDaemonProcess django_app python-path=/home/atms/atms/backend python-home=/home/atms/venv
WSGIProcessGroup django_app
错误日志显示
ImportError: No module named 'backend'
答案 0 :(得分:1)
您已经将Dim postData As String = "{'text': 'je m appellle ihab'}"
Dim tempCookies As New CookieContainer
Dim encoding As New UTF8Encoding
Dim byteData As Byte() = encoding.GetBytes(postData)
Dim postReq As HttpWebRequest = DirectCast(WebRequest.Create("http://www.reverso.net/orthographe/correcteur-francais/ServerInterface.asmx/GetLgDetect"), HttpWebRequest)
postReq.Method = "POST"
postReq.KeepAlive = True
postReq.CookieContainer = tempCookies
postReq.ContentType = "application/json; charset=utf-8"
postReq.Headers.Add(HttpRequestHeader.AcceptEncoding, "gzip, deflate;q=0.8")
postReq.Referer = "http://www.reverso.net/orthographe/correcteur-francais/"
postReq.UserAgent = "Mozilla/5.0 (Windows; U; Windows NT 6.1; ru; rv:1.9.2.3) Gecko/20100401 Firefox/4.0 (.NET CLR 3.5.30729)"
postReq.ContentLength = byteData.Length
postReq.AutomaticDecompression = DecompressionMethods.GZip Or DecompressionMethods.Deflate
Dim postreqstream As Stream = postReq.GetRequestStream()
postreqstream.Write(byteData, 0, byteData.Length)
postreqstream.Close()
Dim postresponse As HttpWebResponse
postresponse = DirectCast(postReq.GetResponse(), HttpWebResponse)
tempCookies.Add(postresponse.Cookies)
logincookie = tempCookies
Dim postreqreader As New StreamReader(postresponse.GetResponseStream())
Dim thepage As String = postreqreader.ReadToEnd
WebBrowser1.DocumentText = thepage
直接放在python路径上,这意味着它本身并不是可导入的名称。您应该将父目录放在那里:
backend