版权声明:本文为博主原创文章,未经博主允许不得转载。http://blog.csdn.net/u014220518 https://blog.csdn.net/u014220518/article/details/82849615
1.错误描述:heroku local web 出现错误Connection in use: ('0.0.0.0', 5000)...
(ll_env) ZFJ:LearningLog zfj$ heroku local
10:07:30 web.1 | [2018-09-26 10:07:30 +0800] [3743] [INFO] Starting gunicorn 19.9.0
10:07:30 web.1 | [2018-09-26 10:07:30 +0800] [3743] [ERROR] Connection in use: ('0.0.0.0', 5000)
10:07:30 web.1 | [2018-09-26 10:07:30 +0800] [3743] [ERROR] Retrying in 1 second.
10:07:31 web.1 | [2018-09-26 10:07:31 +0800] [3743] [ERROR] Connection in use: ('0.0.0.0', 5000)
10:07:31 web.1 | [2018-09-26 10:07:31 +0800] [3743] [ERROR] Retrying in 1 second.
10:07:32 web.1 | [2018-09-26 10:07:32 +0800] [3743] [ERROR] Connection in use: ('0.0.0.0', 5000)
10:07:32 web.1 | [2018-09-26 10:07:32 +0800] [3743] [ERROR] Retrying in 1 second.
10:07:33 web.1 | [2018-09-26 10:07:33 +0800] [3743] [ERROR] Connection in use: ('0.0.0.0', 5000)
10:07:33 web.1 | [2018-09-26 10:07:33 +0800] [3743] [ERROR] Retrying in 1 second.
10:07:34 web.1 | [2018-09-26 10:07:34 +0800] [3743] [ERROR] Connection in use: ('0.0.0.0', 5000)
10:07:34 web.1 | [2018-09-26 10:07:34 +0800] [3743] [ERROR] Retrying in 1 second.
10:07:35 web.1 | [2018-09-26 10:07:35 +0800] [3743] [ERROR] Can't connect to ('0.0.0.0', 5000)
[DONE] Killing all processes with signal SIGINT
10:07:35 web.1 Exited with exit code null
解决办法: kill `lsof -i :5000`
(ll_env) ZFJ:LearningLog zfj$ kill `lsof -i :5000`
-bash: kill: COMMAND: arguments must be process or job IDs
-bash: kill: PID: arguments must be process or job IDs
-bash: kill: USER: arguments must be process or job IDs
-bash: kill: FD: arguments must be process or job IDs
-bash: kill: TYPE: arguments must be process or job IDs
-bash: kill: DEVICE: arguments must be process or job IDs
-bash: kill: SIZE/OFF: arguments must be process or job IDs
-bash: kill: NODE: arguments must be process or job IDs
-bash: kill: NAME: arguments must be process or job IDs
-bash: kill: AirServer: arguments must be process or job IDs
-bash: kill: zfj: arguments must be process or job IDs
-bash: kill: 11u: arguments must be process or job IDs
-bash: kill: IPv4: arguments must be process or job IDs
-bash: kill: 0x2e00b17d95b871cf: arguments must be process or job IDs
-bash: kill: 0t0: arguments must be process or job IDs
-bash: kill: TCP: arguments must be process or job IDs
-bash: kill: *:commplex-main: arguments must be process or job IDs
-bash: kill: (LISTEN): arguments must be process or job IDs
-bash: kill: AirServer: arguments must be process or job IDs
-bash: kill: zfj: arguments must be process or job IDs
-bash: kill: 12u: arguments must be process or job IDs
-bash: kill: IPv6: arguments must be process or job IDs
-bash: kill: 0x2e00b17d813922bf: arguments must be process or job IDs
-bash: kill: 0t0: arguments must be process or job IDs
-bash: kill: TCP: arguments must be process or job IDs
-bash: kill: *:commplex-main: arguments must be process or job IDs
-bash: kill: (LISTEN): arguments must be process or job IDs
2.错误描述:'block' tag with name 'content' appears more than once
因为block content在html文本中出现多次,block content即使是被注释了也不行;删除注释的block content部分就OK了。
3.错误描述:UnicodeDecodeError: 'ascii' codec can't decode byte 0xe6 in position 0: ordinal not in range(128)
这是因为ascii编码的问题,导入gb18030就OK了
import sys
reload(sys)
sys.setdefaultencoding(‘gb18030')
4.错误描述:name 'FileNotFoundError' is not defined
FileNotFoundError是Python3文本不存在的异常处理方法,在Python3.0以下的版本使用IOError。
5.错误描述:SyntaxError: Non-ASCII character '\xe5' in file *******
这是因为Python的默认编码文件用的是ASCII,将文件转为UTF-8,直接在头文件导入以下代码就行;
# -*- coding: UTF-8 -*- 或者 #coding=utf-8
注意:这句代码一定要添加在源码的第一行;
6.在终端Python2.7上使用input的时候,输入的内容要使用引号括起来,但是使用raw_input不用;
7.错误描述:Invalid HTTP_HOST header: ‘xxx.xxx.x.xxx:5000'. You may need to add u’xxx.xxx.x.xxx’ to ALLOWED_HOSTS.
修改项目的配置文件settings.py中的ALLOWED_HOSTS项;
原代码:ALLOWED_HOSTS = []
可以在ALLOWED_HOSTS中添加你的请求地址,如下:
ALLOWED_HOSTS = ['192.168.1.103', 'localhost', '0.0.0.0']
扫描二维码关注公众号,回复:
3829995 查看本文章
也可以这样写:
ALLOWED_HOSTS = ['*']
最后一种是让项目支持所有的主机头,方便部署。