-
Notifications
You must be signed in to change notification settings - Fork 68
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 on Windows system #1018
Comments
Thanks. Can you post the python traceback shown when the error occurs? |
Also, what do you get when running import sys
print(sys.getdefaultencoding()) ? |
Alternatively, can you check whether PR #1020 solves the issue? |
Hi, thanks for you hints. Because I am on a trip abroad, I will give it a try in two days and give you a feedback. |
Hi. the current results of sys.getdefaultencoding() are "utf-8". A strange phenomenon is that when I go back to the origin version of "conversion.py" it seems that my PC still works. How can I test this PR in my local PC machine? |
@Mickychen00 - You will have to install from source, and a clone of the PR branch. There is plenty of git documentation available about cloning a branch. The exact procedure might depend on your git client. With the git CLI it should look like: git clone -b consistent_r2py_str_encoding-issue1018 --single-branch git@github.com:rpy2/rpy2.git You'll have install rpy2 (e.g., |
The issue is not windows-specific. I got the same error on Ubuntu 20.04.4 LTS. rpy2 version '3.5.15'. |
I encountered a UnicodeDecodeError when trying to call an R plot code using rpy2 on my Windows PC. The error message read "UnicodeDecodeError: 'utf-8' codec can't decode byte 0xce in position 81: invalid continuation byte". Strangely, the same code worked well on my Mac laptop.
Luckily, I found a potential solution to this problem in a simplified Chinese blog post. The author pointed out a bug in the rpy2\rinterface_lib\conversion.py file and provided a revised version of the code that solves the issue.
Original code:
Revised code:
Once I implemented the author's revised code, the UnicodeDecodeError disappeared and the code worked perfectly. However, I don't fully understand why this solution works. Can anyone suggest a better solution? Thank you!
The text was updated successfully, but these errors were encountered: