Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

error in python #28

Open
woal777 opened this issue Apr 18, 2018 · 3 comments
Open

error in python #28

woal777 opened this issue Apr 18, 2018 · 3 comments

Comments

@woal777
Copy link

woal777 commented Apr 18, 2018

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
Copy link
Owner

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
Copy link
Author

woal777 commented Apr 18, 2018

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
Copy link

whzhangg commented May 9, 2019

@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\ )

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

3 participants