LoginSignup
4
4

More than 5 years have passed since last update.

radon実行しようとしたらUnicodeEncodeError

Posted at

環境情報

python 3.5.1
OS version 4.4.41-36.55.amzn1.x86_64 (Amazon Linux AMI release 2016.09)

状況

radon使って複雑度計測しようと思って意気揚々とpip installしたまではいいが、radonコマンドで実行するとUnicodeのエラーが出力される。
Unicode系のエラー出ると、でたよーって思うよね。

ERROR: 'ascii' codec can't decode byte 0xe5 in position 47: ordinal not in range(128)

エラーになったプログラムは単体実行できるし、そもそも日本語はコメントアウト部のみ。

pypiを確認すると、環境変数設定しろって書いてある。
https://pypi.python.org/pypi/radon

Note about file encoding

On some systems, such as Windows, the default encoding is not UTF-8. If you are using Unicode characters in your Python file and want to analyze it with Radon, you’ll have to set the RADONFILESENCODING environment variable to UTF-8.

Windowsではないけど、試しに設定する。

環境変数設定

環境変数「RADONFILESENCODING」自体が存在していないことを確認。

export -p

環境変数「RADONFILESENCODING」を追加。

declare -x RADONFILESENCODING="UTF-8"

再確認

改めてradonコマンドを実行

manage.py
    F 36:0 main - A (2)

通ったー。
windowsって書いてあったからスルーしてたわー。

4
4
0

Register as a new user and use Qiita more conveniently

  1. You get articles that match your needs
  2. You can efficiently read back useful information
  3. You can use dark theme
What you can do with signing up
4
4