Importing pipista modules in Editorial
How to import a python module in Editorial
I needed to import the python-wordpress-xmlrpc library for uploading images to the WordPress Media Library on my blog directly from Editorial so the images ends up in the media section in WordPress. I didn’t want to use FTP or SFTP. So here is how to import (and use) that module.
First you need Pipista. I’m using version 2 unstable because it unzips the file automatically, so everything is done for you. It also puts the modules in a separate directory so it doesn’t clutter up your filesystem.
- First we need to get the pipista script into Editorial. So go to the pipista GitHub page and download the script as a text file. (You can just select the text and paste it into a text file.)
- Name the file pipista.py
- Upload the pipista.py file to Editorial with iTunes
- Go to the Console and write the following lines. Enter each line separately and end with return.
You should now have the module installed and ready to go.
Using the new module in your scripts
Because the directory with the modules aren’t in the system path, you need to add that at the top of your script before trying to import a module. Just write
And now you can import you’re newly installed modules.
from wordpress_xmlrpc.compat import xmlrpc_client
from wordpress_xmlrpc.methods import media, posts
And there you go!