Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

'ascii' codec can't decode byte 0xc3 in position 361 at open('README.md').read(), #16

Closed
dz0ny opened this issue May 17, 2015 · 7 comments · Fixed by #22 or #28
Closed

'ascii' codec can't decode byte 0xc3 in position 361 at open('README.md').read(), #16

dz0ny opened this issue May 17, 2015 · 7 comments · Fixed by #22 or #28

Comments

@dz0ny
Copy link

dz0ny commented May 17, 2015

  Downloading unicode-slugify-0.1.3.tar.gz
    Complete output from command python setup.py egg_info:
    Traceback (most recent call last):
      File "<string>", line 20, in <module>
      File "/tmp/pip-build-s4ot22tg/unicode-slugify/setup.py", line 7, in <module>
        long_description=open('README.md').read(),
      File "/var/cache/drone/src/github.com/dz0ny/app/.tox/py34/lib/python3.4/encodings/ascii.py", line 26, in decode
        return codecs.ascii_decode(input, self.errors)[0]
    UnicodeDecodeError: 'ascii' codec can't decode byte 0xc3 in position 361: ordinal not in range(128)
@dz0ny
Copy link
Author

dz0ny commented May 17, 2015

missing read().encode('utf-8') > convert to bytes :)

@pahaz
Copy link

pahaz commented Jul 27, 2015

same issues

==> default: Collecting unicode-slugify==0.1.3 (from -r requirements.txt (line 6))
==> default:   Downloading unicode-slugify-0.1.3.tar.gz
==> default:     Complete output from command python setup.py egg_info:
==> default:     Traceback (most recent call last):
==> default:       File "<string>", line 20, in <module>
==> default:       File "/tmp/pip-build-v2uel0_x/unicode-slugify/setup.py", line 7, in <module>
==> default:         long_description=open('README.md').read(),
==> default:       File "/DATA/venv/lib/python3.4/encodings/ascii.py", line 26, in decode
==> default:         return codecs.ascii_decode(input, self.errors)[0]
==> default:     UnicodeDecodeError: 'ascii' codec can't decode byte 0xc3 in position 361: ordinal not in range(128)
==> default:
==> default:     ----------------------------------------
==> default: Command "python setup.py egg_info" failed with error code 1 in /tmp/pip-build-v2uel0_x/unicode-slugify
The SSH command responded with a non-zero exit status. Vagrant
assumes that this means the command failed. The output for this command
should be in the log above. Please read the output to determine what
went wrong.

@kirsle
Copy link

kirsle commented Jul 28, 2015

This issue was fixed once before in PR #9 and then reverted in 02c2006

A work-around I found is to set the system locale to UTF-8. For example, when using Docker with the Ubuntu base image, the locale is not set by default and this error comes up when trying to install this module. Add these commands to the Dockerfile to work around this (found here):

RUN locale-gen en_US.UTF-8
ENV LANG en_US.UTF-8
ENV LANGUAGE en_US:en

Or, if not using Docker just run the commands at the shell (and look into how to set them permanently so they persist on reboot, e.g. Ubuntu Locale):

root# locale-gen en_US.UTF-8
root# export LANG en_US.UTF-8
root# export LANGUAGE en_US:en

@grimlaufer
Copy link

I had the same error, changing line 7 in setup.py to
long_description=open('README.md', 'r', encoding='utf-8').read() fixed it for me.

@vigneshsarma
Copy link

Can I give a pull request with @grimlaufer's solution? I am also facing this issue.

@marceltschoppch
Copy link
Contributor

I just added a pull request with the solution from @grimlaufer, slightly adjusted to not break environments with python < 3.0

laurentperrinet added a commit to bicv/LogGabor that referenced this issue Oct 5, 2017
laurentperrinet added a commit to bicv/SLIP that referenced this issue Oct 5, 2017
laurentperrinet added a commit to bicv/SparseEdges that referenced this issue Oct 5, 2017
nitely added a commit to nitely/unicode-slugify that referenced this issue Jan 3, 2018
The encoding was being set for python 3 but it used the default system encoding on Python 2 which is not always utf-8 and so it may raise decoding error due to the unicode characters being used within the readme
nitely added a commit to nitely/unicode-slugify that referenced this issue Jan 3, 2018
The encoding was being set for python 3 but it used the default system encoding on Python 2 which is not always utf-8 and so it may raise decoding error due to the unicode characters being used within the readme
davedash pushed a commit that referenced this issue Jan 3, 2018
The encoding was being set for python 3 but it used the default system encoding on Python 2 which is not always utf-8 and so it may raise decoding error due to the unicode characters being used within the readme
@jerkyrs
Copy link

jerkyrs commented Jun 1, 2018

Sorry i know this is old thread but if you are using Docker container assuming you are doing something like this

RUN yum -y update
RUN yum -y install epel-release
RUN yum -y install centos-release-scl centos-release-scl-rh
RUN yum -y install git
RUN yum -y install python36 rh-python36-python rh-python36-python-pip rh-python36-python-virtualenv

Make sure you add your ENV after the above

RUN localedef -i en_US -f UTF-8 C.UTF-8 
ENV LANG="C.UTF-8"
ENV LC_LANG="C.UTF-8"

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
7 participants