Forum

Author Topic: file python text encoding  (Read 3853 times)

lmg

  • Newbie
  • *
  • Posts: 30
    • View Profile
file python text encoding
« on: April 14, 2014, 04:10:39 PM »
I have some problems with the file coding of python files. When I modify a python script and then I save again the file, there are some strange characters, maybe depending on the encoding of the text editor used. When I recall the py file using the "Run python script" command of the console, the run stops immediately, giving this log:

File "O:/PS101_frame_proc__40D_4cams.py", line 3
    import PhotoScan
            ^
SyntaxError: invalid character in identifier

The first lines of my python script file are:

path="C:\Users\Public\Documents\3D_D40\23_09_13_15_35\sc0"
file_name="sc0"
?»?import PhotoScan
import os
import sys
app = PhotoScan.Application()
path_cal="C:\Users\Public\Documents\Sc3D"  #path for the calibration files
file_cal="C:\Users\Public\Documents\Sc3D\Cal_13.txt"

Note that the "?»?" characters where not intentionally written, but they apper in the file.
Please, what is the right encoding of the python file? ANSI, Unicode, UTF-8 or some others?
Thank you very much for your help.

Alexey Pasumansky

  • Agisoft Technical Support
  • Hero Member
  • *****
  • Posts: 13990
    • View Profile
Re: file python text encoding
« Reply #1 on: April 14, 2014, 04:22:56 PM »
Hello lmg,

In the file provided there are BOM symbols that are not supported by Python interpreter, So I recommend to use UTF-8 without BOM encoding. Usually this marks appear in the very beginning of the file, but here it might be copied from another file.

Also please note that in path strings you need to use "/" (slash) symbol or double back slashes "\\".
Best regards,
Alexey Pasumansky,
Agisoft LLC

lmg

  • Newbie
  • *
  • Posts: 30
    • View Profile
Re: file python text encoding
« Reply #2 on: April 15, 2014, 12:59:02 AM »
Ok. Thank you very much. I have solved the problem with your help.
Bye