Installing New Plugin - How to Install Additional Python Modules

I have my plugin working in PyCharm. I can’t get it to load in my non-dev Picard install.

My plugin uses a few additional Python modules. How do I get them installed in my non-dev setup?

If you use the packaged Picard installs for Windows or macOS they come with their own Python install, and your are limited to the modules it has bundled. Everything else needed by the plugin needs to be included as part of the ZIP.

If you have additional modules that are available as Python code than you can often include that module / package in the plugin sources. If it is a compiled C module the plugin will be limited to the platforms for which the module is compiled for. If additional external DLL files are required this pretty much won’t work (I did some experiments with this for my opencc plugin, but it is such a dirty hack that I never submitted this plugin).

Which additional modules is it your plugin needs?

1 Like

I’m not sure it’s a module issue. My list of imports is:

from picard.ui.itemviews import BaseAction, register_album_action
import sqlite3
from sqlite3 import Error
import requests
import json
import os
import shutil
from mutagen.flac import FLAC #, Picture
import urllib
import datetime
import sys, getopt

Most from this list should be fine, with two exceptions:

  • requests: Not used by Picard, and your plugin shouldn’t use it either. Use Picard’s webservice module instead by accessing tagger.webservice. See e.g.
  • sqlite3: I think you are pretty much out of luck with this. You need to use some other solution to store your data. For what do you need it?

I’m copying data from Picard to my own music server database. The sqlite3 is necessary.

As I said you probably won’t have luck with sqlite3. You could try to copy the entire sqlite3 package with all needed depdencies into your plugin’s folder. You need the sqlite DLLs somewhere as well, probably inside the Picard folder. But I have no idea if this will work or which obstacles you’ll encounter.

An alternative approach could be that you create a separate tool that handles accessing the sqlite database and which is a normal Python script running on your computer using the globally installed Python. Then you call this script as an executable from inside your plugin, and pass it the necessary paramaters.

1 Like