Unicode Error: 'utf-8' codec can’t Decode byte when installing rpy2 with Pip

Asked

Viewed 1,126 times

1

I’m trying to install rpy2 which is a package to run R language in python, but gives the error:

$ pip install rpy2

< Using cached rpy2-2.9.2.tar.gz
Exception:
Traceback (most recent call last):
  File "C:\ProgramData\Anaconda3\lib\site-packages\pip\compat\__init__.py", line
 73, in console_to_str
    return s.decode(sys.__stdout__.encoding)
UnicodeDecodeError: 'utf-8' codec can't decode byte 0xc6 in position 6: invalid
continuation byte

During handling of the above exception, another exception occurred:

Traceback (most recent call last):
  File "C:\ProgramData\Anaconda3\lib\site-packages\pip\basecommand.py", line 215
, in main
    status = self.run(options, args)
  File "C:\ProgramData\Anaconda3\lib\site-packages\pip\commands\install.py", lin
e 335, in run
    wb.build(autobuilding=True)
  File "C:\ProgramData\Anaconda3\lib\site-packages\pip\wheel.py", line 749, in b
uild
    self.requirement_set.prepare_files(self.finder)
  File "C:\ProgramData\Anaconda3\lib\site-packages\pip\req\req_set.py", line 380
, in prepare_files
    ignore_dependencies=self.ignore_dependencies))
  File "C:\ProgramData\Anaconda3\lib\site-packages\pip\req\req_set.py", line 634
, in _prepare_file
    abstract_dist.prep_for_dist()
  File "C:\ProgramData\Anaconda3\lib\site-packages\pip\req\req_set.py", line 129
, in prep_for_dist
    self.req_to_install.run_egg_info()
  File "C:\ProgramData\Anaconda3\lib\site-packages\pip\req\req_install.py", line
 439, in run_egg_info
    command_desc='python setup.py egg_info')
  File "C:\ProgramData\Anaconda3\lib\site-packages\pip\utils\__init__.py", line
676, in call_subprocess
    line = console_to_str(proc.stdout.readline())
  File "C:\ProgramData\Anaconda3\lib\site-packages\pip\compat\__init__.py", line
 75, in console_to_str
    return s.decode('utf_8')
UnicodeDecodeError: 'utf-8' codec can't decode byte 0xc6 in position 6: invalid
continuation byte >

Versions:
Python 3.6.1 |Anaconda 4.4.0 (64-bit Pip 9.0.1

  • Which version of Pip and python is being used? Check with pip --version

  • @rodorgas edited the question and put the versions of python, anaconda and Pip.

  • despite being another package, it is the same problem that is in the question that I marked as duplicate. In the answer there is described a way to make it work without needing the Pip upgrade.

1 answer

1

I believe it’s about an encoding error for Pip 9.0.1, which has already been fixed and will be available on Pip 10.

To not have to wait for Pip 10, you can install the development version with:

pip install git+https://github.com/pypa/pip.git

From what I saw affects Windows users with special characters in the project path, so a possible gambiarra is to change your project folder to a path without special characters.

Another gambiarra, which can work in the stable version of Pip, would run the following command before installing a package:

chcp 65001

Pull request link on Github fixing the issue: https://github.com/pypa/pip/pull/4486

  • I typed the Pip install +link from github, but it gives the error: nt-type: text/html; charset=utf-8); cannot Detect Archive format Cannot determine Archive format of C: Users USUARIO Appdata Local Temp Pip-c6bt1 4ed-build. I will delete the anaconda installation that I installed for all users and will reinstall only for my user.

  • @Sorry, the command for installation is wrong. The correct is pip install git+https://github.com/pypa/pip.git instead of pip install https://github.com/pypa/pip. I always miss this :p

Browser other questions tagged

You are not signed in. Login or sign up in order to post.