Forum Moderators: Staff
Poser Python Scripting F.A.Q (Last Updated: 2024 Dec 02 3:16 pm)
adp001 posted at 6:39AM Sat, 16 January 2021 - #4410436
Same error if you write
print("Something")
Thank you for your response.
I tried as follows.
script
print("!!! test !!!")
import sys
print(sys.version)
Results (D:\usr\poser\scripts\test.py)
File "", line 1
SyntaxError: (unicode error) 'unicodeescape' codec can't decode bytes in position 2-3: truncated uXXXX escape
!!! test !!!
3.7.9 (tags/v3.7.9:13c94747c7, Aug 17 2020, 18:58:18) [MSC v.1900 64 bit (AMD64)]
Results (D:\poser\scripts\test.py)
!!! test !!!
3.7.9 (tags/v3.7.9:13c94747c7, Aug 17 2020, 18:58:18) [MSC v.1900 64 bit (AMD64)]
The results are the same as before.
As code it works fine for me from a location with similar path.
Solution: Try to copy your code to notepad and save from there in a new file.
I have had similar issues with code I copied from a conversation in Slack. In my case that had left some non-printable chacarcters. Notepad is not sophisticated enough to deal with those so it just filters them out.!
FVerbaas posted at 9:57AM Sat, 16 January 2021 - #4410453
Solution: Try to copy your code to notepad and save from there in a new file.
Thank you for your response.
I created a new script by copying and pasting on Notepad, but the trouble was not solved.
D:\usr\poser\scripts> type test.py * <- old script
print("!!! test !!!")
import sys
print(sys.version)
D:\usr\poser\scripts>
D:\usr\poser\scripts> type test2.py * <- new(copied) script
print("!!! test !!!")
import sys
print(sys.version)
D:\usr\poser\scripts>
D:\usr\poser\scripts> fc /b test.py test2.py
Comparing files test.py and TEST2.PY
FC: no differences encountered
D:\usr\poser\scripts>
D:\usr\poser\scripts> certutil -dump test.py
0000 ...
0037
0000 70 72 69 6e 74 28 22 21 21 21 20 74 65 73 74 20 print("!!! test
0010 21 21 21 22 29 0d 0a 69 6d 70 6f 72 74 20 73 79 !!!")..import sy
0020 73 0d 0a 70 72 69 6e 74 28 73 79 73 2e 76 65 72 s..print(sys.ver
0030 73 69 6f 6e 29 0d 0a sion)..
CertUtil: -dump command completed successfully.
D:\usr\poser\scripts>
Results (D:\usr\poser\scripts\test2.py)
File "", line 1
SyntaxError: (unicode error) 'unicodeescape' codec can't decode bytes in position 2-3: truncated uXXXX escape
!!! test !!!
3.7.9 (tags/v3.7.9:13c94747c7, Aug 17 2020, 18:58:18) [MSC v.1900 64 bit (AMD64)]
Results (D:\poser\scripts\test2.py)
!!! test !!!
3.7.9 (tags/v3.7.9:13c94747c7, Aug 17 2020, 18:58:18) [MSC v.1900 64 bit (AMD64)]
That seems to be a problem that depends on my environment.
I would like to solve it by using "D:\poser\scripts".
This site uses cookies to deliver the best experience. Our own cookies make user accounts and other features possible. Third-party cookies are used to display relevant ads and to analyze how Renderosity is used. By using our site, you acknowledge that you have read and understood our Terms of Service, including our Cookie Policy and our Privacy Policy.
When I run a script with [File]-[Run Python Script] on the Windows version of 12.0.340, I get an error.
It seems that the error occurs depending on the pathname.
D:\usr\poser\scripts\test.py
Results
Is "\usr" in the pathname interpreted as an escape in the internal process....?
Changing the pathname to "D:\poser\scripts\test.py" works fine.