Open narasimha1805 opened 4 years ago
It is a UnicodeDecodeError. Maybe this example can make some help for understanding about the error.
file = open(filename, encoding="utf8")
For a solution, find futil.py file installed in your computer. (d:\python\lib\site-packages\nlpia\futil.py)
find function named ensure_open and edit some code.
fin = f
if isinstance(f, basestring):
if len(f) <= MAX_LEN_FILEPATH:
f = find_filepath(f) or f
if f and (not hasattr(f, 'seek') or not hasattr(f, 'readlines')):
if f.lower().endswith('.gz'):
return gzip.open(f, mode=mode,encoding='UTF-8')
return open(f, mode=mode,encoding='UTF-8')
f = fin # reset path in case it is the text that needs to be opened with StringIO
else:
f = io.StringIO(f)
elif f and getattr(f, 'closed', None):
if hasattr(f, '_write_gzip_header'):
return gzip.open(f.name, mode=mode,encoding='UTF-8')
else:
return open(f.name, mode=mode,encoding='UTF-8')
return f
I just added ",encoding='UTF-8'" when open() comes out.
Doesn't work for me either, whats the problem?
It is a UnicodeDecodeError. Maybe this example can make some help for understanding about the error.
file = open(filename, encoding="utf8")
For a solution, find futil.py file installed in your computer. (d:\python\lib\site-packages\nlpia\futil.py)
find function named ensure_open and edit some code.
fin = f if isinstance(f, basestring): if len(f) <= MAX_LEN_FILEPATH: f = find_filepath(f) or f if f and (not hasattr(f, 'seek') or not hasattr(f, 'readlines')): if f.lower().endswith('.gz'): return gzip.open(f, mode=mode,encoding='UTF-8') return open(f, mode=mode,encoding='UTF-8') f = fin # reset path in case it is the text that needs to be opened with StringIO else: f = io.StringIO(f) elif f and getattr(f, 'closed', None): if hasattr(f, '_write_gzip_header'): return gzip.open(f.name, mode=mode,encoding='UTF-8') else: return open(f.name, mode=mode,encoding='UTF-8') return f
I just added ",encoding='UTF-8'" when open() comes out.
Unfortunately that prints this error: File "gensim/_matutils.pyx", line 1, in init gensim._matutils ValueError: numpy.ndarray size changed, may indicate binary incompatibility. Expected 88 from C header, got 80 from PyObject
It is a UnicodeDecodeError. Maybe this example can make some help for understanding about the error. file = open(filename, encoding="utf8") For a solution, find futil.py file installed in your computer. (d:\python\lib\site-packages\nlpia\futil.py) find function named ensure_open and edit some code.
fin = f if isinstance(f, basestring): if len(f) <= MAX_LEN_FILEPATH: f = find_filepath(f) or f if f and (not hasattr(f, 'seek') or not hasattr(f, 'readlines')): if f.lower().endswith('.gz'): return gzip.open(f, mode=mode,encoding='UTF-8') return open(f, mode=mode,encoding='UTF-8') f = fin # reset path in case it is the text that needs to be opened with StringIO else: f = io.StringIO(f) elif f and getattr(f, 'closed', None): if hasattr(f, '_write_gzip_header'): return gzip.open(f.name, mode=mode,encoding='UTF-8') else: return open(f.name, mode=mode,encoding='UTF-8') return f
I just added ",encoding='UTF-8'" when open() comes out.
Unfortunately that prints this error: File "gensim/_matutils.pyx", line 1, in init gensim._matutils ValueError: numpy.ndarray size changed, may indicate binary incompatibility. Expected 88 from C header, got 80 from PyObject
ah, nvm. this fixes it. thank you!
It is a UnicodeDecodeError. Maybe this example can make some help for understanding about the error.
file = open(filename, encoding="utf8")
For a solution, find futil.py file installed in your computer. (d:\python\lib\site-packages\nlpia\futil.py)
find function named ensure_open and edit some code.
fin = f if isinstance(f, basestring): if len(f) <= MAX_LEN_FILEPATH: f = find_filepath(f) or f if f and (not hasattr(f, 'seek') or not hasattr(f, 'readlines')): if f.lower().endswith('.gz'): return gzip.open(f, mode=mode,encoding='UTF-8') return open(f, mode=mode,encoding='UTF-8') f = fin # reset path in case it is the text that needs to be opened with StringIO else: f = io.StringIO(f) elif f and getattr(f, 'closed', None): if hasattr(f, '_write_gzip_header'): return gzip.open(f.name, mode=mode,encoding='UTF-8') else: return open(f.name, mode=mode,encoding='UTF-8') return f
I just added ",encoding='UTF-8'" when open() comes out.
Thanks, it works!
Getting 'UnicodeDecodeError: 'charmap' codec can't decode byte 0x9d in position 360: character maps to' error while importing word_topic_vectors from nlpia.book.examples.ch04_catdog_las*
Below is the error:
UnicodeDecodeError Traceback (most recent call last)