Python研究ノートエラー収集



Python Study Notes Error Collection



1.エラーの説明:herokuローカルWebにエラー接続が使用されています:( '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

解決策: `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.エラーの説明:「content」という名前の「block」タグが複数回表示されます

ブロックコンテンツはHTMLテキストに複数回表示されるため、ブロックコンテンツはコメントアウトされません。コメントのブロックコンテンツ部分を削除しても問題ありません。



3.エラーの説明:UnicodeDecodeError: 'ascii'コーデックは位置0のバイト0xe6をデコードできません:序数がrange(128)にありません

これはASCIIコーディングの問題のためです。インポートgb18030は問題ありません。



import sys reload(sys) sys.setdefaultencoding(‘gb18030')

4.エラーの説明:名前 'FileNotFoundError'が定義されていません

FileNotFoundErrorは、Python3テキストには存在しない例外処理メソッドです。 IOErrorは、Python3.0より前のバージョンで使用されます。

5.エラーの説明:SyntaxError:ファイル内の非ASCII文字 ' xe5' *******

これは、PythonのデフォルトのエンコーディングファイルがASCIIを使用し、ファイルをUTF-8に変換し、次のコードをヘッダーファイルに直接インポートするためです。

#-*-コーディング:UTF-8-*-または#coding = utf-8
注:このコードは、ソースコードの最初の行に追加する必要があります



6.ターミナルPython2.7で入力を使用する場合、入力は引用符で囲む必要がありますが、raw_inputは使用しないでください。

7.エラーの説明:無効なHTTP_HOSTヘッダー:「xxx.xxx.x.xxx:5000」。 ALLOWED_HOSTSにu’xxx.xxx.x.xxx ’を追加する必要がある場合があります。

プロジェクトの構成ファイルsettings.pyのALLOWED_HOSTSアイテムを変更します

元のコード:ALLOWED_HOSTS = []

次のように、ALLOWED_HOSTSにリクエストアドレスを追加できます。

ALLOWED_HOSTS = ['192.168.1.103'、 'localhost'、 '0.0.0.0']

次のように書くこともできます:

ALLOWED_HOSTS = ['*']

最後は、プロジェクトがすべてのホストヘッダーをサポートできるようにして、展開を容易にすることです。