ajjackson / ascii-phonons

Blender extensions for illustrations of phonons
GNU General Public License v3.0
60 stars 22 forks source link

error in python #28

Open woal777 opened 6 years ago

woal777 commented 6 years ago

I just use the example file, but it has a problem in python.

import sys from os.path import pathsep

sys.path = ['D:\programFiles\ascii-phonons-master\addons'] + sys.path

import bpy import vsim2blender import vsim2blender.plotter

config = vsim2blender.read_config(user_config='C:\Users\JINHO-~1\AppData\Local\Temp\tmphryt1lxd')

Final line made the problem (SyntaxError: (unicode error) 'unicodeescape' codec can't decode bytes in position 2-3: truncated \UXXXXXXXX escape).

ajjackson commented 6 years ago

Thanks for posting here! I see the problem; the \U in your Windows file path is being interpreted as a special character. Probably we need to ensure the backslashes are escaped (i.e. replaced with "\") when passed to the script file. Unfortunately I don't have a Windows development setup so it's not easy for me to experiment with this.

(Also, Python3 tends to be better-behaved when it comes to unicode so perhaps I should migrate this project.)

woal777 commented 6 years ago

Thanks to reply i think r'` expression is more suitable in any environment. but i don't know which files create temporary python file. thanks.

whzhangg commented 5 years ago

@woal777 @ajjackson Maybe this is no longer helpful to you but: I have the same problem where the path contains escape characters. The function that creates the temporary file is located in ascii_phonons/init.py . You can find "addons_path" that stores the path. You can directly change this path to a fixed path according to your system. I tried to incert some code to change the system path that contains the ugly ' \ ' by '\' according to the method as suggested in this post: http://code.activestate.com/recipes/65211-convert-a-string-into-a-raw-string/ . But it is not working very well because of the "\a" problem in python and I gave up (the system can not tell \a from \7 apart but the natural path contains \ascii_phonons\ )