nirum / tableprint

Pretty console printing :clipboard: of tabular data in python :snake:
https://tableprint.readthedocs.io/
MIT License
174 stars 16 forks source link

Error executing on windows #4

Open acnazarejr opened 7 years ago

acnazarejr commented 7 years ago

I try this:

import tableprint as tp
tp.banner('test')

error:

Traceback (most recent call last):
  File "stats.py", line 83, in <module>
    main()
  File "C:\Users\acnazarejr\Anaconda3\envs\harhealth-sensors\lib\site-packages\click\core.py", line 722, in __call__
    return self.main(*args, **kwargs)
  File "C:\Users\acnazarejr\Anaconda3\envs\harhealth-sensors\lib\site-packages\click\core.py", line 697, in main
    rv = self.invoke(ctx)
  File "C:\Users\acnazarejr\Anaconda3\envs\harhealth-sensors\lib\site-packages\click\core.py", line 1066, in invoke
    return _process_result(sub_ctx.command.invoke(sub_ctx))
  File "C:\Users\acnazarejr\Anaconda3\envs\harhealth-sensors\lib\site-packages\click\core.py", line 895, in invoke
    return ctx.invoke(self.callback, **ctx.params)
  File "C:\Users\acnazarejr\Anaconda3\envs\harhealth-sensors\lib\site-packages\click\core.py", line 535, in invoke
    return callback(*args, **kwargs)
  File "stats.py", line 40, in dataset
    tp.banner('title_text')
  File "C:\Users\acnazarejr\Anaconda3\envs\harhealth-sensors\lib\site-packages\tableprint\printer.py", line 259, in banner
    out.write(header([message], max(width, len(message)), style) + '\n')
  File "C:\Users\acnazarejr\Anaconda3\envs\harhealth-sensors\lib\site-packages\colorama\ansitowin32.py", line 40, in write
    self.__convertor.write(text)
  File "C:\Users\acnazarejr\Anaconda3\envs\harhealth-sensors\lib\site-packages\colorama\ansitowin32.py", line 141, in write
    self.write_and_convert(text)
  File "C:\Users\acnazarejr\Anaconda3\envs\harhealth-sensors\lib\site-packages\colorama\ansitowin32.py", line 169, in write_and_convert
    self.write_plain_text(text, cursor, len(text))
  File "C:\Users\acnazarejr\Anaconda3\envs\harhealth-sensors\lib\site-packages\colorama\ansitowin32.py", line 174, in write_plain_text
    self.wrapped.write(text[start:end])
  File "C:\Users\acnazarejr\Anaconda3\envs\harhealth-sensors\lib\site-packages\colorama\ansitowin32.py", line 40, in write
    self.__convertor.write(text)
  File "C:\Users\acnazarejr\Anaconda3\envs\harhealth-sensors\lib\site-packages\colorama\ansitowin32.py", line 141, in write
    self.write_and_convert(text)
  File "C:\Users\acnazarejr\Anaconda3\envs\harhealth-sensors\lib\site-packages\colorama\ansitowin32.py", line 169, in write_and_convert
    self.write_plain_text(text, cursor, len(text))
  File "C:\Users\acnazarejr\Anaconda3\envs\harhealth-sensors\lib\site-packages\colorama\ansitowin32.py", line 174, in write_plain_text
    self.wrapped.write(text[start:end])
  File "C:\Users\acnazarejr\Anaconda3\envs\harhealth-sensors\lib\encodings\cp1252.py", line 19, in encode
    return codecs.charmap_encode(input,self.errors,encoding_table)[0]
UnicodeEncodeError: 'charmap' codec can't encode characters in position 0-31: character maps to <undefined>

Python version: 3.5.3 OS: Windows 10

nirum commented 7 years ago

Hi, thanks for bringing this up! I unfortunately haven't tested tableprint on windows and was unaware of this problem. It looks like there is a simple solution (I just need to add a .encode('utf-8') to a string before printing it, but I will double check and get back to you!

tintinweb commented 6 years ago

hey @nirum, I am thinking about using your lib to print tables on a windows application and I am encountering the same problem. any update here?