python3.6で日本語を出力したい
python3.6で日本語がprintできません。
現在、「増補改訂Pythonによるスクレイピング&機械学習 開発テクニック」を読み始め、環境構築中です。
Dockerの概念や操作もあまりわからないです。
発生している問題・エラーメッセージ
UnicodeEncodeError: 'ascii' codec can't encode characters in position 0-2: ordinal not in range(128)
該当のソースコード
:/#coding: UTF-8
jstr = "日本語"
print(jstr)
試したこと
一応、ja_JP.utf8は入っている↓
:/# locale -a
locale: Cannot set LC_CTYPE to default locale: No such file or directory
locale: Cannot set LC_MESSAGES to default locale: No such file or directory
locale: Cannot set LC_COLLATE to default locale: No such file or directory
C
C.UTF-8
POSIX
ja_JP.utf8
これが何かまずい?↓
:/# locale
LANG=
LANGUAGE=
LC_CTYPE="POSIX"
LC_NUMERIC="POSIX"
LC_TIME="POSIX"
LC_COLLATE="POSIX"
LC_MONETARY="POSIX"
LC_MESSAGES="POSIX"
LC_PAPER="POSIX"
LC_NAME="POSIX"
LC_ADDRESS="POSIX"
LC_TELEPHONE="POSIX"
LC_MEASUREMENT="POSIX"
LC_IDENTIFICATION="POSIX"
LC_ALL=
変えようとしたがエラー?↓
:/# locale-gen ja_JP.UTF-8
/bin/bash: warning: setlocale: LC_ALL: cannot change locale (en_US.UTF-8)
Generating locales (this might take a while)...
ja_JP.UTF-8... done
Generation complete.
実行してもこうなる↓
:/# python3.6 test2.py
bash: warning: setlocale: LC_ALL: cannot change locale (en_US.UTF-8)
bash: warning: setlocale: LC_ALL: cannot change locale (en_US.UTF-8)
bash: warning: setlocale: LC_ALL: cannot change locale (en_US.UTF-8)
bash: warning: setlocale: LC_ALL: cannot change locale (en_US.UTF-8)
bash: warning: setlocale: LC_ALL: cannot change locale (en_US.UTF-8)
bash: warning: setlocale: LC_ALL: cannot change locale (en_US.UTF-8)
bash: warning: setlocale: LC_ALL: cannot change locale (en_US.UTF-8)
bash: warning: setlocale: LC_ALL: cannot change locale (en_US.UTF-8)
bash: warning: setlocale: LC_ALL: cannot change locale (en_US.UTF-8)
bash: warning: setlocale: LC_ALL: cannot change locale (en_US.UTF-8)
Traceback (most recent call last):
File "test2.py", line 3, in <module>
print(jstr)
UnicodeEncodeError: 'ascii' codec can't encode characters in position 0-2: ordinal not in range(128)
補足情報(FW/ツールのバージョンなど)
ここにより詳細な情報を記載してください。