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

UnicodeDecodeError: 'ascii' codec can't decode byte 0xe2 in position 604 #80

Closed
bartmika opened this issue Apr 28, 2016 · 7 comments
Closed

Comments

@bartmika
Copy link

Hello, I am running Python 3.4 on a FreeBSD box and I ran the following command:

pip install django-tenants

But unfortunately it errors, here's the output:

Collecting django-tenants
  Downloading django-tenants-1.1.5.zip (87kB)
    100% |################################| 92kB 2.5MB/s
    Complete output from command python setup.py egg_info:
    Traceback (most recent call last):
      File "<string>", line 1, in <module>
      File "/tmp/pip-build-kblbhq12/django-tenants/setup.py", line 31, in <module>
        long_description=open('README.rst').read() if exists("README.rst") else "",
      File "/usr/home/django/py-bizmula/env/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 0xe2 in position 604: ordinal not in range(128)

    ----------------------------------------
Command "python setup.py egg_info" failed with error code 1 in /tmp/pip-build-kblbhq12/django-tenants/

Any way we can fix this? Thanks!

@rodolfomartinez
Copy link

+1

1 similar comment
@viralrain
Copy link

+1

@kosz85
Copy link
Contributor

kosz85 commented Apr 29, 2016

For python 3.5 it's working, so I checked Python 3.4.4 and... ...it's also working?

Python 3.4.4 (default, Mar  7 2016, 03:46:01) 
[GCC 5.3.1 20160225] on linux
Type "help", "copyright", "credits" or "license" for more information.
>>> import django_tenants
>>> dir(django_tenants)
['__builtins__', '__cached__', '__doc__', '__file__', '__loader__', '__name__', '__package__', '__path__', '__spec__', 'default_app_config']

I think it's smth internal in your python interpreter minor version or system. Please check all versions, I installed it with:

Python 3.4.4
pip 8.1.1

Provide your versions of python, pip, and system itself.

@bartmika
Copy link
Author

bartmika commented Apr 29, 2016

I have two machines running two different OSes and here are the info:

OS X
Version - 10.11.4
Python 3.4.2
pip 1.5.6
django-tentants works

FreeBSD
Version - 10.2
Python 3.4.4 (More specific: python34-3.4.4_2)
pip 8.1.1
django-tentants does not work

@bartmika
Copy link
Author

Update: I have emailed the FreeBSD package managers at python@FreeBSD.org. Hopefully, they can look into this as well.

@bartmika
Copy link
Author

Problem Identified
The file README.rst has non-ascii characters in it but python is trying
to read it as an ascii file

Specifically it uses the "right single quotation mark" instead of a
"modifier letter apostrophe" or a simple ascii apostrophe

https://tedclancy.wordpress.com/2015/06/03/which-unicode-character-should-represent-the-english-apostrophe-and-why-the-unicode-committee-is-very-wrong/

This would be an automatic thing from the text editor used.

Solution(s)

  1. Either remove all non-ascii apostrophies from the README.rst file

  2. Or in the setup.py file, replace line 31 with:

    long_description=open('README.rst', encoding='utf-8').read() if exists("README.rst") else "",
  3. Or I can write in my OS this variable:

    using tcsh -
    % setenv  LC_ALL en_US.UTF-8
    
    using sh -
    % LC_ALL=en_US.UTF-8;export LC_ALL

Moving Forward with a Fix
I can make a pull request to fix this ticket using solution (2).

@bartmika
Copy link
Author

bartmika commented May 1, 2016

Okay so the fix I went with was just setting my env to support 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
Development

No branches or pull requests

4 participants