使用pip安装flask-bcrypt时出现的一个错误是:UnicodeDecodeError:'ascii'编解码器无法解码字节0xe6,位置为49的数字不在范围内(128)

2024-03-29 09:48:18 发布

您现在位置:Python中文网/ 问答频道 /正文

今天,当我安装bcrypt使用的烧瓶时:

pip install flask-bcrypt

发生此错误:

^{pr2}$

Tags: installpipflask烧瓶错误bcryptpr2
2条回答

你可以试着跟着

export LANG=en_US.UTF-8
pip install flask-bcrypt

在命令下键入pythonshell时

>>> import sys
>>> sys.getdefaultencoding()

它将输出:

^{pr2}$

所以,我修改

/etc/python2.7/sitecustomize.py

添加:

import sys
sys.setdefaultencoding('utf-8')

现在,defaultencoding更改为:

'utf-8'

此错误已解决,但也有另一个错误:

Command /home/sf/python/venv/bin/python2 -c "import setuptools,  
tokenize;__file__='/tmp/pip-build-6LgjpC/bcrypt/setup.py';
exec(compile(getattr(tokenize, 'open', open)(__file__).read().replace('\r\n', 
'\n'), __file__, 'exec'))" install  record /tmp/pip-3qxBJi-record/install-
record.txt  single-version-externally-managed  compile  install-headers 
/home/sf/python/venv/include/site/python2.7 failed with error code 1 in 
/tmp/pip-build-6LgjpC/bcrypt
Storing debug log for failure in /home/sf/.pip/pip.log

你可以看到这个:when I try to install Flask-bcrypt it throws me error: command 'x86_64-linux-gnu-gcc' failed with exit status 1

我只安装:

apt-get install libffi-dev

最后,我成功地安装了烧瓶bcrypt。在

相关问题 更多 >