Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

UnicodeDecodeError: 'ascii' codec can't decode byte 0xe2 in position 36 #83

Closed
msongz opened this issue Feb 14, 2020 · 8 comments
Closed

Comments

@msongz
Copy link

msongz commented Feb 14, 2020

确保你已经看过 readme,也搜索并阅读过和你遇到的情况相关的问题。否则会被认为是重复的并被立刻关闭。

描述问题
清晰并准确地描述问题。

复现问题
复现问题的步骤:

  1. 你使用的命令行参数。
  2. 一份完整的autosub命令行输出。你可以使用Ctrl-ACtrl-C去复制所有输出。推荐使用以下的代码块markdown语法。
UnicodeDecodeError: 'ascii' codec can't decode byte 0xe2 in position 36: ordinal not in range(128)
Warning: Speech language "en" not recommended. Run with "-lsc"/"--list-speech-codes" to see all supported languages.
Destination language not provided. Only performing speech recognition.
Speech language is the same as the Destination language. Only performing speech recognition.
Traceback (most recent call last):
  File "/usr/local/bin/autosub", line 8, in <module>
    sys.exit(main())
  File "/usr/local/lib/python2.7/site-packages/autosub/__init__.py", line 147, in main
    styles_list=styles_list)
  File "/usr/local/lib/python2.7/site-packages/autosub/cmdline_utils.py", line 867, in audio_or_video_prcs
    out_=audio_wav)
UnicodeDecodeError: 'ascii' codec can't decode byte 0xe2 in position 36: ordinal not in range(128)
Warning: Speech language "en" not recommended. Run with "-lsc"/"--list-speech-codes" to see all supported languages.
Destination language not provided. Only performing speech recognition.
Speech language is the same as the Destination language. Only performing speech recognition.
Traceback (most recent call last):
  File "/usr/local/bin/autosub", line 8, in <module>
    sys.exit(main())
  File "/usr/local/lib/python2.7/site-packages/autosub/__init__.py", line 147, in main
    styles_list=styles_list)
  File "/usr/local/lib/python2.7/site-packages/autosub/cmdline_utils.py", line 867, in audio_or_video_prcs
    out_=audio_wav)
UnicodeDecodeError: 'ascii' codec can't decode byte 0xe2 in position 36: ordinal not in range(128)
  1. 等等

期待的行为
清晰并准确地描述你本想做的事情。

截图
合适的话可以提供用以描述问题的截图。但是不推荐用截图来展示命令行输出,除非你真的认为这很有必要。

操作环境(请提供以下完整数据):

  • 操作系统: [譬如 windows] macOS 10.13.6
  • Python版本: [譬如 Python 2.7] 2.7
  • Autosub版本: [譬如 0.4.0] 最新提交

额外信息(可选)
任何其他的能描述问题的信息。

@BingLingGroup
Copy link
Owner

已知问题,python 2.7在windows下无法正确读取命令行中输入的中文字符,是python 2.7的问题,虽然有解决方法但是比较复杂,python 3可以直接解决这个问题,建议换用python 3。
类似问题 #51

@lucddcc
Copy link

lucddcc commented Feb 15, 2020

冰灵大神好,为啥我在ubuntu 下 也出现了 类似解码错误呀?, 用的是教程里的例子视频。

$ autosub -i '/home/x-x/下载/videoplayback.mp4' -S en -D zh -hsp -of all -bm all
警告:语音语言"en"不在推荐的清单里面。用"-lsc"/"--list-speech-codes"选项运行来查看所有支持的语言。
现在匹配语言代码。
输入: en
分数高于: 90
匹配结果 分数(0-100)
en-us 99
en-ng 97
en-nz 97
en-au 97
en-in 97
en-ph 97
en-ie 97
en-gb 97
en-gh 97
en-tz 97
en-sg 97
en-ke 97
en-ca 97
en-za 97
Use langcodes to standardize the result.
改用"en-US"。
翻译源语言未提供。改用语音语言。
警告:源语言"en-US"不在推荐的清单里面。用 "-lsc"/"--list-translation-codes"选项运行来查看所有支持的语言。
现在匹配语言代码。
输入: en-US
分数高于: 90
匹配结果 分数(0-100)
en 99
改用"en"。
警告:不支持目的语言"zh"。用 "-lsc"/"--list-translation-codes"选项运行来查看所有支持的语言。
现在匹配语言代码。
输入: zh
分数高于: 90
匹配结果 分数(0-100)
zh-cn 99
改用"zh-cn"。
Traceback (most recent call last):
File "/usr/local/bin/autosub", line 10, in
sys.exit(main())
File "/usr/local/lib/python2.7/dist-packages/autosub/init.py", line 147, in main
styles_list=styles_list)
File "/usr/local/lib/python2.7/dist-packages/autosub/cmdline_utils.py", line 867, in audio_or_video_prcs
out_=audio_wav)
UnicodeDecodeError: 'ascii' codec can't decode byte 0xe4 in position 10: ordinal not in range(128)

@BingLingGroup
Copy link
Owner

@lucddcc https://stackoverflow.com/questions/33811930/best-way-to-decode-command-line-inputs-to-unicode-python-2-7-scripts 这个问题看起来不仅是windows上会有,linux也有,确实是python2.7的问题

@lucddcc
Copy link

lucddcc commented Feb 15, 2020

@BingLingGroup ok 在phyton 3 上运行了 。不过安装命令在phyton 3下 apt install ffmpeg python python-pip git -y 应是 apt install ffmpeg python python3-pip git -y 。

@msongz
Copy link
Author

msongz commented Feb 15, 2020

@BingLingGroup 谢谢,我mac环境,如何切换到python 3?
是不是安装的时候用pip3?

@BingLingGroup
Copy link
Owner

@lucddcc 好,我等下改readme
@msongz 好像是pip3吧,我一般用脚本安装 https://pip.pypa.io/en/stable/installing/

@msongz
Copy link
Author

msongz commented Feb 15, 2020

sudo pip3 install .

Traceback (most recent call last):
  File "/usr/local/bin/autosub", line 5, in <module>
    from autosub import main
  File "/usr/local/lib/python3.7/site-packages/autosub/__init__.py", line 15, in <module>
    from autosub import ffmpeg_utils
  File "/usr/local/lib/python3.7/site-packages/autosub/ffmpeg_utils.py", line 25, in <module>
    fallback=True)
  File "/usr/local/Cellar/python/3.7.6_1/Frameworks/Python.framework/Versions/3.7/lib/python3.7/gettext.py", line 518, in translation
    mofiles = find(domain, localedir, languages, all=True)
  File "/usr/local/Cellar/python/3.7.6_1/Frameworks/Python.framework/Versions/3.7/lib/python3.7/gettext.py", line 490, in find
    for nelang in _expand_lang(lang):
  File "/usr/local/Cellar/python/3.7.6_1/Frameworks/Python.framework/Versions/3.7/lib/python3.7/gettext.py", line 212, in _expand_lang
    loc = locale.normalize(loc)
  File "/usr/local/Cellar/python/3.7.6_1/Frameworks/Python.framework/Versions/3.7/lib/python3.7/locale.py", line 401, in normalize
    code = localename.lower()
AttributeError: 'NoneType' object has no attribute 'lower'

@BingLingGroup
Copy link
Owner

BingLingGroup commented Feb 16, 2020

@msongz 似乎是macOS自己的问题 ewdurbin/evacuate_2stp#1 (comment)
缺少语言环境变量LANGLC_ALL,需要自己export

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

3 participants