简体   繁体   中英

Got UnicodeDecodeError when installing SQLAlchemy via pip

I'm trying to install SQLAlchemy via pip. However, I failed.

My OS is Windows 10 Chinese version and I'm using Python 3.6.0.

I searched my problem on the Internet and got many solutions said that I can add sys.setdefaultencoding to some file. But I'm using Python3.

I also found an issue on Github which seems to be exactly my problem. But changing my code page to 866 or 65001 doesn't work at all ...

Here's the information:

C:\Users\59740>pip install SQLAlchemy
Collecting SQLAlchemy
  Using cached SQLAlchemy-1.1.4.tar.gz
Installing collected packages: SQLAlchemy
  Running setup.py install for SQLAlchemy ... error
Exception:
Traceback (most recent call last):
  File "c:\program files\python36\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 0xb6 in position 34: invalid start byte

During handling of the above exception, another exception occurred:

Traceback (most recent call last):
  File "c:\program files\python36\lib\site-packages\pip\basecommand.py", line 215, in main
    status = self.run(options, args)
  File "c:\program files\python36\lib\site-packages\pip\commands\install.py", line 342, in run
    prefix=options.prefix_path,
  File "c:\program files\python36\lib\site-packages\pip\req\req_set.py", line 784, in install
    **kwargs
  File "c:\program files\python36\lib\site-packages\pip\req\req_install.py", line 878, in install
    spinner=spinner,
  File "c:\program files\python36\lib\site-packages\pip\utils\__init__.py", line 676, in call_subprocess
    line = console_to_str(proc.stdout.readline())
  File "c:\program files\python36\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 0xb6 in position 34: invalid start byte

open \\python36\\lib\\site-packages\\pip\\compat__init__.py 75 return s.decode(' utf_8 ') change to

return s.decode(' cp936 ')

other: chcp cmd show you current code page

我解决了这个问题,将“\\python36\\lib\\site-packages\\pip\\compat__init__.py”(感谢之前的评论)中的 75 行更改为return s.decode('latin1')

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM