toluaina / pgsync

Postgres to Elasticsearch/OpenSearch sync
https://pgsync.com
MIT License
1.1k stars 172 forks source link

ModuleNotFoundError: No module named 'plugins.' #489

Open insaneadinesia opened 10 months ago

insaneadinesia commented 10 months ago

PGSync version: 2.5.0

Postgres version: postgres (PostgreSQL) 14.8 (Homebrew)

Elasticsearch version: docker.elastic.co/elasticsearch/elasticsearch:7.8.0

Redis version: 7.0.8

Python version: Python 3.8.9

Problem Description: Got ModuleNotFoundError: No module named 'plugins.'1 when define schema with plugins.

class TestPlugin(plugin.Plugin): print('masuk') name = 'Test'

def transform(self, doc, **kwargs):
    print('masuk2')
    doc['test'] = 'masuk'

    print('masuk3')
    return doc

Error Message (if any): 

efishery/pgsync/book took 2s ➜ pgsync --config schema.json -d masuk

4d11 commented 9 months ago

Your directory should be named /Users/mamatosai/efishery/pgsync/plugins

asturm-fe commented 6 months ago

Elaborating on @4d11 's answer: The python module (aka the folder containing your my_plugin.py) must be named "plugins" and must contain an (empty) __init__.py file. The path you add to your PYTHONPATH is then the path to the parent-directory of that module (so you dont include the /plugins-part).