Running python from the command tool. Behaves wierdly

(Rickard Andersson) #1

Im running a small python script from the command tool and some modules does not seem to work: sys.path and logging.
Im on Windows 10, Tiled 0.18.2 and Python 2.7.
My script works when running it from cmd with the arguments that I’ve set up Tiled to run it with. It works when running from Tiled when commenting out the calls to any functionality in sys.path or logging (the modules can be imported without failing)
Also I dont get any console wich is the reason i want to use logging to print error messages to a file.

Thanks for a really nice tool :slight_smile:

(Rickard Andersson) #2

Im just gonna put the following here in case someone has the same problems:
Its just a path issue. When running from the command tool the working directory is the installation directory of Tiled. Probably python does not have rights to create a file i that directory so logging would then fail.
Easily fixed by changing the working dir to same as the script:

Or you can just make a bat script and run that:
cd "C:\Users\me\path\to\my\game\scripts"
python “” %1

(Thorbjørn Lindeijer) #3

Hey @Rickard_Andersson, thanks for letting us know what was causing your problem! Eventually I also hope to allow setting the working directory per command, which is what this issue is about:

On Linux there is a somewhat hidden “Run in terminal” action, but I guess in general it would be useful to print the output of the command into the Debug Console window. I’ve created the following issue for this: