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

String vs. Unicode error with Python 3.5 #21

Open
fnl opened this issue Sep 19, 2016 · 1 comment
Open

String vs. Unicode error with Python 3.5 #21

fnl opened this issue Sep 19, 2016 · 1 comment
Assignees

Comments

@fnl
Copy link

fnl commented Sep 19, 2016

I was trying to use JusText 2.2.0 with Python 3.5.

However, after installing and running one of the example extractions without piping it to a file and just dumping to STDOUT, the following error can be observed:

$ python -m justext -s Czech http://www.zdrojak.cz/clanky/automaticke-zabezpeceni/
Traceback (most recent call last):
  File "/usr/local/Cellar/python3/3.5.1/Frameworks/Python.framework/Versions/3.5/lib/python3.5/runpy.py", line 170, in _run_module_as_main
    "__main__", mod_spec)
  File "/usr/local/Cellar/python3/3.5.1/Frameworks/Python.framework/Versions/3.5/lib/python3.5/runpy.py", line 85, in _run_code
    exec(code, run_globals)
  File "~/lib/python3.5/site-packages/justext/__main__.py", line 318, in <module>
    main()
  File "~/lib/python3.5/site-packages/justext/__main__.py", line 301, in main
    output_default(paragraphs, fp_out)
  File "~/lib/python3.5/site-packages/justext/__main__.py", line 94, in output_default
    print('<%s> %s' % (tag, cgi.escape(paragraph.text)), file=fp)
  File "~/bin/../lib/python3.5/codecs.py", line 377, in write
    self.stream.write(data)
TypeError: write() argument must be str, not bytes
@miso-belica
Copy link
Owner

This is quite a common problem with the Windows console. Are you sure you have OS, console, IO, and everything set to UTF-8 or any other suitable encoding? (UTF-16, ...) There are even some ENV variables to set for Python.

@miso-belica miso-belica self-assigned this Oct 14, 2021
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