Python中与字符编码方式有关的一个错误

  • Post author:
  • Post category:python


1.错误如下:

原始代码中的部分代码如下:

with open(‘README.md’) as f:

readme = f.read()

with open(‘LICENSE’) as f:

license = f.read()

with open(‘requirements.txt’) as f:

reqs = f.read()

Traceback (most recent call last):

File “setup.py”, line 14, in <module>

readme = f.read()

File “/root/anaconda3/lib/python3.6/encodings/ascii.py”, line 26, in decode

return codecs.ascii_decode(input, self.errors)[0]

UnicodeDecodeError: ‘ascii’ codec can’t decode byte 0xe2 in position 8661: ordinal not in range(128)

不使用codecs

修改后的代码如下:

with codecs.open(‘README.md’,’r’,’UTF-8′) as f:

readme = f.read()

with codecs.open(‘LICENSE’,’r’,’UTF-8′) as f:

license = f.read()

with codecs.open(‘requirements.txt’,’r’,’UTF-8′) as f:

reqs = f.read()

然后再编译就可以通过了



2.  ubuntu


系统安装


anaconda3


或者


miniconda3


运行指令,提示


sudo:conda:command not found


解决办法





sudo chown -Rmarley:marley /home/marley/miniconda3



版权声明:本文为qq_33230848原创文章,遵循 CC 4.0 BY-SA 版权协议,转载请附上原文出处链接和本声明。