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

utf8' codec can't decode byte 0x89 in position 0 #79

Open
michaelfillier opened this issue Oct 8, 2012 · 1 comment
Open

utf8' codec can't decode byte 0x89 in position 0 #79

michaelfillier opened this issue Oct 8, 2012 · 1 comment

Comments

@michaelfillier
Copy link

Generation Failed
I am trying to install hyde on windows vista 64-bit. I am getting this error when attempting to run the generator:


Traceback (most recent call last):
File "c:\xampp\htdocs\hyde\hydeengine__init__.py", line 417, in process_all
self.process(resource)
File "c:\xampp\htdocs\hyde\hydeengine__init__.py", line 377, in process
return self.processor.process(item)
File "c:\xampp\htdocs\hyde\hydeengine\processor.py", line 116, in process
TemplateProcessor.process(resource)
File "c:\xampp\htdocs\hyde\hydeengine\media_processors.py", line 15, in proces
s
rendered = render_to_string(resource.source_file.path, settings.CONTEXT)
File "c:\Python27\lib\site-packages\django\template\loader.py", line 169, in r
ender_to_string
t = get_template(template_name)
File "c:\Python27\lib\site-packages\django\template\loader.py", line 145, in g
et_template
template, origin = find_template(template_name)
File "c:\Python27\lib\site-packages\django\template\loader.py", line 134, in f
ind_template
source, display_name = loader(name, dirs)
File "c:\Python27\lib\site-packages\django\template\loader.py", line 42, in __
call__
return self.load_template(template_name, template_dirs)
File "c:\Python27\lib\site-packages\django\template\loader.py", line 45, in lo
ad_template
source, display_name = self.load_template_source(template_name, template_dir
s)
File "c:\Python27\lib\site-packages\django\template\loaders\filesystem.py", li
ne 39, in load_template_source
return (file.read().decode(settings.FILE_CHARSET), filepath)
File "c:\Python27\lib\encodings\utf_8.py", line 16, in decode
return codecs.utf_8_decode(input, errors, True)
UnicodeDecodeError: 'utf8' codec can't decode byte 0x89 in position 0: invalid s
tart byte


I was looking to try out hyde as an alternative to jekyll, since I am in the process of learning python and django. But sadly can't get it running. Any help is appreciated, I will do a little googlin' and see if I come up with a fix. Thanks!

@guneysus
Copy link

I am watching this issue because similar bug is occured at my Windows 8, Python 2.7.5.
And i encountered a similar error with Jekyll and also Hyde

UnicodeDecodeError: 'utf8' codec can't decode byte 0x89 in position 0: invalid start byte (HYDE)

Solved with removing Unicode BOM characters programmatically from my content files. Or manually
from http://stackoverflow.com/a/8898439/1766716

def removeBom(file):
    import os, sys, codecs
    BUFSIZE = 4096
    BOMLEN = len(codecs.BOM_UTF8)

    with open(file, "r+b") as fp:
        chunk = fp.read(BUFSIZE)
        if chunk.startswith(codecs.BOM_UTF8):
            i = 0
            chunk = chunk[BOMLEN:]
            while chunk:
                fp.seek(i)
                fp.write(chunk)
                i += len(chunk)
                fp.seek(BOMLEN, os.SEEK_CUR)
                chunk = fp.read(BUFSIZE)
            fp.seek(-BOMLEN, os.SEEK_CUR)
            fp.truncate()
    return 0

Encode Unicode files to -> Unicode Without BOM.

BUT, i encountered this error at the very beginning of the installation, in other words i have no content files and no content files with Unicode or with UTF without BOM.

Error while rendering page /prerendered/hyde-icon.png
***********************
Generation Failed
(... Lots of text ...)

UnicodeDecodeError: 'utf8' codec can't decode byte 0x89 in position 0: invalid start byte

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

2 participants