randy3k / radian

A 21 century R console
MIT License
1.96k stars 73 forks source link

UnicodeDecodeError: 'utf-8' codec can't decode byte 0xce in position 33: invalid continuation byte #438

Open kebuAAA opened 9 months ago

kebuAAA commented 9 months ago

when run radian in windows 11 by Python 3.10 throw:

Traceback (most recent call last):
  File "c:\Users\lm\AppData\Local\Programs\Python\Python310\Lib\site-packages\radian\__main__.py", line 31, in <module>
    main(cleanup=cleanup)
  File "C:\Users\lm\AppData\Local\Programs\Python\Python310\lib\site-packages\radian\app.py", line 108, in main
    RadianApplication(r_home, ver=__version__).run(options, cleanup=cleanup)
  File "C:\Users\lm\AppData\Local\Programs\Python\Python310\lib\site-packages\radian\app.py", line 217, in run
    rutils.source_radian_profile(options.profile)
  File "C:\Users\lm\AppData\Local\Programs\Python\Python310\lib\site-packages\radian\rutils.py", line 70, in source_radian_profile
    global_profile = user_path(".radian_profile")
  File "C:\Users\lm\AppData\Local\Programs\Python\Python310\lib\site-packages\radian\rutils.py", line 44, in user_path
    return make_path(rcopy(rcall(("base", "path.expand"), "~")), *args)
  File "C:\Users\lm\AppData\Local\Programs\Python\Python310\lib\site-packages\rchitect\dispatch.py", line 53, in __call__
    return func(*args, **kwargs)
  File "C:\Users\lm\AppData\Local\Programs\Python\Python310\lib\site-packages\rchitect\interface.py", line 581, in rcopy
    return rcopy(unbox(r))
  File "C:\Users\lm\AppData\Local\Programs\Python\Python310\lib\site-packages\rchitect\dispatch.py", line 53, in __call__
    return func(*args, **kwargs)
  File "C:\Users\lm\AppData\Local\Programs\Python\Python310\lib\site-packages\rchitect\interface.py", line 569, in rcopy
    return rcopy(T, s)
  File "C:\Users\lm\AppData\Local\Programs\Python\Python310\lib\site-packages\rchitect\dispatch.py", line 53, in __call__
    return func(*args, **kwargs)
  File "C:\Users\lm\AppData\Local\Programs\Python\Python310\lib\site-packages\rchitect\interface.py", line 479, in rcopy
    return _string(lib.STRING_ELT(s, 0))
  File "C:\Users\lm\AppData\Local\Programs\Python\Python310\lib\site-packages\rchitect\interface.py", line 469, in _string
    return text_type(ffi.string(lib.Rf_translateCharUTF8(s)).decode("utf-8"))
UnicodeDecodeError: 'utf-8' codec can't decode byte 0xce in position 33: invalid continuation byte

My R version is 4.3.1 and I'm not sure why this problem happened.

kebuAAA commented 9 months ago

I solved this problem with the guidance in readme. So sorry to bother you.

kebuAAA commented 8 months ago

This setting worked well but it conflicts with my zip.exe. After checking the Beta: Use Unicode UTF-8 for worldwide language support, I will see some garbage characters of file name in my zip file. So I just wonder if there is any otrher solution to deal with this problem.

randy3k commented 8 months ago

What version of radian are you using?

kebuAAA commented 8 months ago

What version of radian are you using?

I'm so sorry for fogetting to provide necessary infomation:

C:\Users\lm>radian --version
radian version: 0.6.7
r executable: D:\R\R-4.3.1\bin\R
r version: 4.3.1
python executable: C:\Users\lm\AppData\Local\Programs\Python\Python310\python.exe 
python version: 3.10.2

And I have solved this problem by adding a new .radian_profile in the %USERPROFILE% to avoid stepping into the elif statement in rutils.py. I think this error happened because the return vallue of the user_path(".radian_profile") contained unicode characters(I changed my defalut saving path). So thankful for your reply.❤️❤️

mqdw222 commented 8 months ago

how to solve this problem?help!help!

kebuAAA commented 8 months ago

how to solve this problem?help!help!

Are you sure you meet the same problem with me? If so, solutions may be:

randy3k commented 8 months ago

Um, I believe that for some reason, user_path(".radian_profile") or base::path.expand("~") has returned a non-utf8 string despite utf-8 locale should have set earlier.

I will be great if you could test if rutils.set_locale is doing its job (unless we have LC_CTYPE set?).