First, if you get this, make sure that you actually have installed the required components (whichever you are missing):
apt install postfix-mysql apt install postfix-pcre
…but my real point here, is that it seems that some (at least it happens on Ubuntu 20) have an issue by missconfiguring the dynamicmaps.cf file in the /etc/postfix directory.
Namely, when you install eg. both extensions, the config file looks like this:
# dict-type so-name (pathname) dict-function mkmap-function pcre postfix-pcre.so dict_pcre_open mysql postfix-mysql.so dict_mysql_open
So, all seems to be allright, except that it’s still throwing the error above. The problem is, that this way it’s looking for the plugin files inside the postfix directory, and since it can’t find them, it can’t find them it still throws the same error. The solution is to add absolute paths to the .so files, which in case of Ubuntu is /usr/lib/postfix/ so, the dynamicmaps.cf file should look like this:
# dict-type so-name (pathname) dict-function mkmap-function pcre /usr/lib/postfix/postfix-pcre.so dict_pcre_open mysql /usr/lib/postfix/postfix-mysql.so dict_mysql_open
Restart Postfix, and voila, problem solved.
This one was driving me crazy…