utf-8 codec can't decode byte 0xd5
1
0
Entering edit mode
yuhang • 0
@1b2a94a4
Last seen 6 weeks ago
Hong Kong

Hi, I am learning to analyze bulk RNA-Seq data using Python. I am using Python3.6 and R 4.2.3.


    import pandas as pd
    import rpy2.robjects as robjects
    from rpy2.robjects import pandas2ri, Formula
    pandas2ri.activate()
    from rpy2.robjects.packages import importr
Everything went well and an error hit me.

    deseq = importr('DESeq2')

## 

    error
    D:\Files\Python\PXF_H_L\venv\Scripts\python.exe D:/Files/Python/PXF_H_L/deseq2_2.py
    From cffi callback <function _consolewrite_ex at 0x164A4AE0>:
    Traceback (most recent call last):
      File "D:\Files\Python\PXF_H_L\venv\lib\site-packages\rpy2\rinterface_lib\callbacks.py", line 132, in _consolewrite_ex
        s = conversion._cchar_to_str_with_maxlen(buf, n, _CCHAR_ENCODING)
      File "D:\Files\Python\PXF_H_L\venv\lib\site-packages\rpy2\rinterface_lib\conversion.py", line 133, in _cchar_to_str_with_maxlen
        s = ffi.string(c, maxlen).decode(encoding)
    UnicodeDecodeError: 'utf-8' codec can't decode byte 0xd5 in position 223: invalid continuation byte
    R[write to console]: Failed with error:  
    R[write to console]: 
    From cffi callback <function _consolewrite_ex at 0x164A4AE0>:
    Traceback (most recent call last):
      File "D:\Files\Python\PXF_H_L\venv\lib\site-packages\rpy2\rinterface_lib\callbacks.py", line 132, in _consolewrite_ex
        s = conversion._cchar_to_str_with_maxlen(buf, n, _CCHAR_ENCODING)
      File "D:\Files\Python\PXF_H_L\venv\lib\site-packages\rpy2\rinterface_lib\conversion.py", line 133, in _cchar_to_str_with_maxlen
        s = ffi.string(c, maxlen).decode(encoding)
    UnicodeDecodeError: 'utf-8' codec can't decode byte 0xce in position 1: invalid continuation byte
    R[write to console]: 
    R[write to console]: 

    From cffi callback <function _consolewrite_ex at 0x164A4AE0>:
    Traceback (most recent call last):
      File "D:\Files\Python\PXF_H_L\venv\lib\site-packages\rpy2\rinterface_lib\callbacks.py", line 132, in _consolewrite_ex
        s = conversion._cchar_to_str_with_maxlen(buf, n, _CCHAR_ENCODING)
      File "D:\Files\Python\PXF_H_L\venv\lib\site-packages\rpy2\rinterface_lib\conversion.py", line 133, in _cchar_to_str_with_maxlen
        s = ffi.string(c, maxlen).decode(encoding)
    UnicodeDecodeError: 'utf-8' codec can't decode byte 0xd5 in position 180: invalid continuation byte
    Traceback (most recent call last):
      File "D:/Files/Python/PXF_H_L/deseq2_2.py", line 6, in <module>
        deseq = importr('DESeq2')
      File "D:\Files\Python\PXF_H_L\venv\lib\site-packages\rpy2\robjects\packages.py", line 484, in importr
        env = _get_namespace(name)
      File "D:\Files\Python\PXF_H_L\venv\lib\site-packages\rpy2\rinterface_lib\conversion.py", line 45, in _
        cdata = function(*args, **kwargs)
      File "D:\Files\Python\PXF_H_L\venv\lib\site-packages\rpy2\rinterface.py", line 680, in __call__
        raise embedded.RRuntimeError(_rinterface._geterrmessage())
      File "D:\Files\Python\PXF_H_L\venv\lib\site-packages\rpy2\rinterface_lib\_rinterface_capi.py", line 438, in _geterrmessage
        res = _string_getitem(res, 0)
      File "D:\Files\Python\PXF_H_L\venv\lib\site-packages\rpy2\rinterface_lib\_rinterface_capi.py", line 286, in _string_getitem
        conversion._R_ENC_PY[openrlib.rlib.Rf_getCharCE(elt)]
      File "D:\Files\Python\PXF_H_L\venv\lib\site-packages\rpy2\rinterface_lib\conversion.py", line 127, in _cchar_to_str
        s = ffi.string(c).decode(encoding)
    UnicodeDecodeError: 'utf-8' codec can't decode byte 0xd5 in position 180: invalid continuation byte
    During startup - Warning message:
    package 'stats' in options("defaultPackages") was not found

I think this error may suggests that there is an issue with decoding a string using the 'utf-8' codec due to an invalid byte sequence.

importr DESeq2 • 315 views
ADD COMMENT
0
Entering edit mode
@mikelove
Last seen 14 hours ago
United States

Sorry, this seems like an issue with importr, not DESeq2, which is supported for R's release and devel branches.

You might instead try pydeseq2:

https://pydeseq2.readthedocs.io/en/latest/

ADD COMMENT
0
Entering edit mode

Thanks! I tried to install PyDESeq2 within a conda environment following the official instruction

 conda env create -n pydeseq2

An error hit me

SpecNotFound: Invalid name, try the format: user/package

Then I googled the error and changed the code

conda create -n pydeseq2

Another error hit me

Solving environment: done

CondaHTTPError: HTTP 000 CONNECTION FAILED for url <https://repo.anaconda.com/pkgs/free/noarch/repodata.json.bz2>
Elapsed: -

An HTTP error occurred when trying to retrieve this URL.
HTTP errors are often intermittent, and a simple retry will get you on your way.

If your current network has https://www.anaconda.com blocked, please file
a support request with your network engineering team.

ConnectionError(MaxRetryError('HTTPSConnectionPool(host=\'repo.anaconda.com\', port=443): Max retries exceeded with url: /pkgs/free/noarch/repodata.json.bz2 (Caused by ReadTimeoutError("HTTPSConnectionPool(host=\'repo.anaconda.com\', p
ort=443): Read timed out. (read timeout=9.15)"))'))

It seems that there's a problem with the connection between my system and the Anaconda repository.

ADD REPLY
0
Entering edit mode

I'm not the maintainer, try contacting them.

ADD REPLY

Login before adding your answer.

Traffic: 602 users visited in the last hour
Help About
FAQ
Access RSS
API
Stats

Use of this site constitutes acceptance of our User Agreement and Privacy Policy.

Powered by the version 2.3.6