在Ubuntu服务器上发版django报错。

本文探讨了在 Django 应用中出现 KeyError: 'REQUEST_METHOD' 的原因及解决方法,指出此错误通常由未正确安装或配置依赖包引起。

摘要生成于 C知道 ,由 DeepSeek-R1 满血版支持, 前往体验 >

Traceback (most recent call last):
  File "/iot/extroniot/env36/lib/python3.6/site-packages/django/core/handlers/wsgi.py", line 141, in __call__
    request = self.request_class(environ)
  File "/iot/extroniot/env36/lib/python3.6/site-packages/django/core/handlers/wsgi.py", line 82, in __init__
    self.method = environ['REQUEST_METHOD'].upper()
KeyError: 'REQUEST_METHOD'
[pid: 20398|app: 0|req: 1/1]  () {16 vars in 368 bytes} [Wed Jul 31 05:13:09 2019]   => generated 0 bytes in 2 msecs ( 500) 0 headers in 0 bytes (0 switches on core 0)
Traceback (most recent call last):
  File "/iot/extroniot/env36/lib/python3.6/site-packages/django/core/handlers/wsgi.py", line 141, in __call__
    request = self.request_class(environ)
  File "/iot/extroniot/env36/lib/python3.6/site-packages/django/core/handlers/wsgi.py", line 82, in __init__
    self.method = environ['REQUEST_METHOD'].upper()
KeyError: 'REQUEST_METHOD'
[pid: 20401|app: 0|req: 1/2]  () {16 vars in 368 bytes} [Wed Jul 31 05:13:09 2019]   => generated 0 bytes in 1 msecs ( 500) 0 headers in 0 bytes (0 switches on core 0)
Traceback (most recent call last):
  File "/iot/extroniot/env36/lib/python3.6/site-packages/django/core/handlers/wsgi.py", line 141, in __call__
    request = self.request_class(environ)
  File "/iot/extroniot/env36/lib/python3.6/site-packages/django/core/handlers/wsgi.py", line 82, in __init__
    self.method = environ['REQUEST_METHOD'].upper()
KeyError: 'REQUEST_METHOD'
[pid: 20398|app: 0|req: 2/3]  () {16 vars in 368 bytes} [Wed Jul 31 05:13:09 2019]   => generated 0 bytes in 0 msecs ( 500) 0 headers in 0 bytes (0 switches on core 0)
Traceback (most recent call last):
  File "/iot/extroniot/env36/lib/python3.6/site-packages/django/core/handlers/wsgi.py", line 141, in __call__
    request = self.request_class(environ)
  File "/iot/extroniot/env36/lib/python3.6/site-packages/django/core/handlers/wsgi.py", line 82, in __init__
    self.method = environ['REQUEST_METHOD'].upper()
KeyError: 'REQUEST_METHOD'

self.method = environ['REQUEST_METHOD'].upper() 的报错,在百度上找了一圈没有找到原因,具体找了一下两个网址:

http://www.h5w3.com/?p=831

https://stackoverflow.com/questions/35607350/python-3-4-3-bottle-with-cgi-environrequest-method

之前一直是运行很正常的,但是不知道为什么这次发版就不行了。

到了最后发现是不知道为啥项目跑出来虚拟空间的范围。

在外面没有相应的包。

所以:

因为没有安装好相应的包。

之前都安装到了虚拟空间里面,但是这次不知道什么原因,虚拟空间的都不管用了。

然后再外面包都给安装好了。

评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值