I'm trying to test a plugin in the Terminal but I keep getting the error:
Traceback (most recent call last):
File "__init__.py", line 1, in
from PMS import Plugin, Log, DB, Thread, XML, HTTP, JSON, RSS, Utils
ImportError: No module named PMS
This happens with the official plugins as well. I tried adding "/Applications/Plex.app/Contents/Resources/Plex/Plex Media Server.app/Contents/Resources/Python/Resources" to the PYTHONPATH environment variable but python still can't see PMS.
Can someone point me in the right direction please?
If I’m not mistaken you are trying to run the plugins directly by executing “python init.py”?
From how I understand it what you want to be doing is running the Plex Media Server (found in /Applications/Plex.app/Contents/Resources/Plex/Plex Media Server.app/Contents/MacOS) from the command line, which will let you see the output produced by it. If it encounters an error in one of the plug-ins you will see it there. Isn’t the most convenient of developing, but that’s just part of the how it’s architected.
This is due to how the plug-in framework was designed. The plug-ins don’t actually run on their own - the framework is loaded first, and the plug-in runs within that. This provides several benefits, including proper response formatting for PMS, automated error checks, exception handling, localization, HTTP caching & cookie support, data storage, resource handling, etc. etc. etc. It wouldn’t be possible to keep the plugins so small & simple without using this method. We also use a few extra libraries (the major one being lxml, which is HUGE improvement over the standard XML libraries included with OS X’s Python) which require special handling to make sure they get used instead of the standard Leopard dylibs.
The media server also logs output to the OS X console, so you can still see it without running in the terminal, and each plug-in has it’s own log file in “~/Library/Logs/PMS Plugin Logs”. Also, you can continue working on your plug-in while it’s running under the media server - any changes to Info.plist or init.py will cause PMS to restart the plug-in. Personally, I find the combination of a text editor, a running Plex + PMS combo and Console.app monitoring the plug-in’s log file to be quite a productive environment to work with
Yeah, “tail -f” is definitely your friend in this case. I suppose it’s just not the most conventional way to debug python scripts so some confusion is understandable.
Sorry, I can see how it’s all a bit confusing compared to “regular” Python programming, especially when there’s very little information available Also, I apologise for any inconsistencies or downright stupid things in the framework code - once things quieten down after the release we’ll be cleaning everything up & releasing proper tutorials & documentation. Until then, feel free to PM me if you have any more questions