Forum

Author Topic: cmd to runscript *.py ,Redirect output message to cmd error  (Read 1576 times)

空空

  • Newbie
  • *
  • Posts: 26
    • View Profile
cmd to runscript *.py ,Redirect output message to cmd error
« on: January 08, 2019, 11:38:31 AM »
when I run python in runscript mode  .eg:    photoscan.exe -r test.py
the words with encoding utf-8 redirect to cmd is not show correctly,   It show a empty Line with no words.
but when  i print letter ,it goes correct.   

eg:
print(u'中国')                       cmd output enpty line .
print(u'chinese')                cmd output 'chinese '

Is there any encoding convert needed?

Alexey Pasumansky

  • Agisoft Technical Support
  • Hero Member
  • *****
  • Posts: 14813
    • View Profile
Re: cmd to runscript *.py ,Redirect output message to cmd error
« Reply #1 on: January 08, 2019, 08:10:54 PM »
Hello,

Have you followed the guidelines related to source encoding?
https://www.python.org/dev/peps/pep-0263/

For example, what happens, if you add the following line to the script body:
Code: [Select]
# -*- coding: utf-8 -*-And what is the script output with these two lines like in your example, if executed by the system Python?
Best regards,
Alexey Pasumansky,
Agisoft LLC

空空

  • Newbie
  • *
  • Posts: 26
    • View Profile
Re: cmd to runscript *.py ,Redirect output message to cmd error
« Reply #2 on: January 09, 2019, 09:29:40 AM »
Hi Alexey:
Thanks for your reply.
the img attached is my python code and Windows cmd output 。

空空

  • Newbie
  • *
  • Posts: 26
    • View Profile
Re: cmd to runscript *.py ,Redirect output message to cmd error
« Reply #3 on: January 09, 2019, 09:31:45 AM »
by the way , the output a,b,c  in PhotoScan is output correctly,but cmd is error.