Redirection error

7 views
Skip to first unread message

Jostein Berntsen

unread,
Nov 2, 2010, 6:48:23 AM11/2/10
to notetaking...@googlegroups.com
If I try to a redirect from n.py this error occurs:

Traceback (most recent call last):
File "/usr/local/bin/n.py", line 5, in <module>
pkg_resources.run_script('nts==52', 'n.py')
File "/usr/lib/python2.6/site-packages/pkg_resources.py", line 489, in run_script
self.require(requires)[0].run_script(script_name, ns)
File "/usr/lib/python2.6/site-packages/pkg_resources.py", line 1207, in run_script
execfile(script_filename, namespace, namespace)
File "/usr/local/lib/python2.6/site-packages/nts-52-py2.6.egg/EGG-INFO/scripts/n.py", line 17, in <module>
main()
File "/usr/local/lib/python2.6/site-packages/nts-52-py2.6.egg/EGG-INFO/scripts/n.py", line 14, in main
nts.ntsData.main()
File "/usr/local/lib/python2.6/site-packages/nts-52-py2.6.egg/nts/ntsData.py", line 658, in main
print_tree(lofl)
File "/usr/local/lib/python2.6/site-packages/nts-52-py2.6.egg/nts/ntsData.py", line 357, in print_tree
print "%s%s" % (tab*(i+1), line)
UnicodeEncodeError: 'ascii' codec can't encode character u'\xf8' in position 44: ordinal not in range(128)

Should it be like this? Is there an export option for output?


Jostein

Dan Graham

unread,
Nov 2, 2010, 8:40:17 AM11/2/10
to Note Taking Simplified
Try setting the environmental variable PYTHONIOENCODING to utf_8. I
have the following in my ~/.bash_profile:

export PYTHONIOENCODING=utf_8

The problem seems to be that python can determine the encoding when
printing to the terminal but gets confused when the output is
redirected.

There is an option to export selected notes in the gui but not
currently in the command line version though it could be added.

-Dan

Jostein Berntsen

unread,
Nov 2, 2010, 8:48:17 AM11/2/10
to Note Taking Simplified
On 02.11.10,05:40, Dan Graham wrote:
> Try setting the environmental variable PYTHONIOENCODING to utf_8. I
> have the following in my ~/.bash_profile:
>
> export PYTHONIOENCODING=utf_8
>
> The problem seems to be that python can determine the encoding when
> printing to the terminal but gets confused when the output is
> redirected.
>
> There is an option to export selected notes in the gui but not
> currently in the command line version though it could be added.
>
> -Dan
>

That worked great, thanks.


Jostein


Reply all
Reply to author
Forward
0 new messages