Hi, I have a number of scripts in the Workspace "scripts" folder, using the sys.path.append() method I am oftem but seeminlgy randomly getting errors when trying to run scripts that import scripts in the same directory:
from scripting import *
# get a CityEngine instance
ce = CE()
sys.path.append( ce.toFSPath("scripts/") )
import myModule
Sometimes it works fine, but often I get an error and the scripts refuses to run:
File "<string>", line 1, in <module> File "<...>\CityEngine_TestProject01\scripts\<script>.py", line 17, in <module> sys.path.append(ce.toFSPath("scripts/")) NameError: name 'sys' is not defined
... which is odd as "sys" ought to always be available and it periodically works and then doesnt work.
After reloading CityEngine and trying a script it appears that some scripts work and some dont but it always seems to be random as to which ones will succeed and which wont.
😐 appears that one of the imported scripts wasnt importing "sys".
Fixed by adding "import sys" to the scripts ( the Python console does this automatically but the auto-generated *.py scripts do not, thet only import "scripting" )