Skip to content

UnicodeEncodeError: 'ascii' codec can't encode character '\u2019' #175

@binarybottle

Description

@binarybottle

Running:

mindboggle $FREESURFER_SUBJECT --out $OUT --no_volumes --no_moments --no_spectra --no_sulci

results in UnicodeEncodeError in multiple places within nipype:

Traceback (most recent call last):
File "/opt/miniconda-latest/envs/mb/lib/python3.6/site-packages/nipype/pipeline/plugins/linear.py", line 48, in run
node.run(updatehash=updatehash)
File "/opt/miniconda-latest/envs/mb/lib/python3.6/site-packages/nipype/pipeline/engine/nodes.py", line 487, in run
self, report_type='postexec', is_mapnode=isinstance(self, MapNode))
File "/opt/miniconda-latest/envs/mb/lib/python3.6/site-packages/nipype/pipeline/engine/utils.py", line 225, in write_report
fp.write('\n'.join(lines))
UnicodeEncodeError: 'ascii' codec can't encode character '\u2019' in position 1641: ordinal not in range(128)

This is despite the fact that within the docker container, UTF-8 is set by default:

root@374580a45eb2:/opt# locale -a
C
C.UTF-8
en_US.utf8
POSIX

and seems resistant to setting ENV PYTHONIOENCODING=utf-8

or running (https://stackoverflow.com/questions/43356982/docker-python-set-utf-8-locale):
docker run -e PYTHONIOENCODING=UTF-8 ...

The only thing that seems to work is to set "encoding='utf-8'" in the nipype python functions themselves.

I have left an issue in the nipy/nipype repo: nipy/nipype#2942

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions