tqdm/tqdm

pypy + PyCharm + tqdm = UnicodeEncodeError

CrazyPython opened this issue · 4 comments

This only occurs in PyCharm Run/Debug, not terminal. Spotted on PyPy for Python 2

I tested using:

from tqdm import trange
import time

for i in trange(10):
    time.sleep(0.02)

Traceback:

Traceback (most recent call last):
  File "/Users/james/Algorithms Course/scratch.py", line 4, in <module>
    for i in trange(10):
  File "/usr/local/Cellar/pypy/5.3.0/libexec/site-packages/tqdm/_tqdm.py", line 624, in __iter__
    1 / avg_time if avg_time else None, bar_format))
  File "/usr/local/Cellar/pypy/5.3.0/libexec/site-packages/tqdm/_tqdm.py", line 98, in print_status
    fp_write('\r' + s + (' ' * max(last_len[0] - len_s, 0)))
  File "/usr/local/Cellar/pypy/5.3.0/libexec/site-packages/tqdm/_tqdm.py", line 91, in fp_write
    fp.write(_unicode(s))
UnicodeEncodeError: 'ascii' codec can't encode characters in position 6-10: ordinal not in range(128)

would be fixable with trange(..., ascii=True). Probably PyCharm reporting
unicode support where it doesn't really exist. Might be able to catch this
in tqdm...

On 22 July 2016 at 20:05, CrazyPython notifications@github.com wrote:

This only occurs in PyCharm Run/Debug, not terminal. Spotted on PyPy for
Python 2

I tested using:

from tqdm import trange
import time

for i in trange(10):
time.sleep(0.02)

Traceback:

Traceback (most recent call last):
File "/Users/james/Algorithms Course/scratch.py", line 4, in
for i in trange(10):
File "/usr/local/Cellar/pypy/5.3.0/libexec/site-packages/tqdm/_tqdm.py", line 624, in iter
1 / avg_time if avg_time else None, bar_format))
File "/usr/local/Cellar/pypy/5.3.0/libexec/site-packages/tqdm/_tqdm.py", line 98, in print_status
fp_write('\r' + s + (' ' * max(last_len[0] - len_s, 0)))
File "/usr/local/Cellar/pypy/5.3.0/libexec/site-packages/tqdm/_tqdm.py", line 91, in fp_write
fp.write(_unicode(s))
UnicodeEncodeError: 'ascii' codec can't encode characters in position 6-10: ordinal not in range(128)


You are receiving this because you are subscribed to this thread.
Reply to this email directly, view it on GitHub
#208, or mute the thread
https://github.com/notifications/unsubscribe-auth/AKR9mzO_36tlywiilSQ8LT38BBIpxDX-ks5qYRR3gaJpZM4JTCtA
.

Yes but I'm not sure we should make specific exceptions for all environments that are just wrong in their handling of unicode

Also @CrazyPython I can't remember but are you running Windows? Because if that's the case, the culprit may be a faulty detection of the OS inside an IDE such as PyCharm.

@lrq3000 nope, Mac OS X El Captain

Windows has "C:" prepended to path names, btw.

pycharm has other issues: #307 #203