Python module isn't working

Hi

I’ve installed Tiled 32bit for windows, latest version + Python3, the python.dll module could not start (shown in red the Plugin window), despite the fact the doc says it supports Python3.

So I installed python 2.7 and now the python.dll module is shown in green, but it doesn’t add any entry to the Export dialog.
The doc says putting scripts in a ‘script’ folder that doesn’t exist, so I ended up creating this folder in Tiled install directory, but still, no python export available.

Is it a bug? or did i just missed something?

The stable manual still says Python 2.7, unless you clicked to the “latest” version, which applies to the development snapshots. They mention Python 3, though that snapshot still needs to be released (the switch to Python 3 is causing the AppImage for Linux to not start).

No, the plugin itself adds no entries, it only adds entries for scripts that it can find.

The documentation could be clearer here about the location where it expects the scripts. ~/.tiled is not the Tiled install directory. It is a “.tiled” directory in your home folder. I’m not sure where it is on Windows, but to find out you could start “cmd” and type “echo %HOME%”.

Thanks for your answer.
Unfortunately it still does not work, it finds the script but in the Tiled debug console it says :

image

The file is is example.py, contents copied from the 2.7 manual page.
I’ve tried adding the .tiled dir to my path but it doesn’t help. What could be wrong ?

Ok so I think there is a bug in Tiled. To make the python script work, it needs to exist in ~/.tiled/ AND in the application’s directory (otherwise you get the ‘no module named ***’ error).

Also, choosing a path with accentuated characters for the export crashes the script :
Traceback (most recent call last):
File “example.py”, line 14, in write
with open(fileName, ‘w’) as fileHandle:
IOError: [Errno 2] No such file or directory: ‘C:/Users/\xc3\xa9/Documents/test.example’

(real user name in this example is ‘é’ without the quotes)

Please remove it again, this is not related to your path. The message in the console refers to the Python import path. But, I have no idea what could cause the “No module named example” import error.

I don’t see how it can matter at all what you put in the application’s directory. I’ll see if I can reproduce this problem on Windows.

Hmm, that appears to be some encoding problem. Let’s see if that will get resolved by the upgrade to Python 3. Please try one of these builds, which should be shipping a Python 3 plugin:

https://ci.appveyor.com/project/bjorn/tiled/build/1.1.3233

Click to one of the Jobs and then to ARTIFACTS, there you will find either the installer or a 7-Zip archive, the latter should be the easiest to try if you have 7-Zip installed. Of course, these builds will need Python 3 to be installed as well. Note that I haven’t tried them yet.

This version works better ! It fixed the encoding problem and needs only the scripts to be in ~/.tiled

1 Like