lightningd / plugins

Community curated plugins for core-lightning
BSD 3-Clause "New" or "Revised" License
269 stars 129 forks source link

Error when starting lightningd with plugin path #10

Closed Coinomatron closed 5 years ago

Coinomatron commented 5 years ago

File "/home/user/lightning/plugins/plugins/rebalance/rebalance.py", line 2, in from lightning import Plugin, Millisatoshi, RpcError ModuleNotFoundError: No module named 'lightning'

Does it matter where the plugin is located?

Johnstedt commented 5 years ago

AFAIK the path shouldn't matter.

Have you installed pylightning? It contains the module that the error highlights.

You may install it with pip install pylightning or see pylightning

m-schmoock commented 5 years ago

@Coinomatron

You can also set the PYTHONPATH environment variable, as the source comes with the pyligthning in contrib folder

PYTHONPATH=/hoe/user/lnrepo/contrib/pythonpath:$PYTHONPATH  /hoe/user/lnrepo/lightningd/lightningd --plugin=...
Coinomatron commented 5 years ago

pip install did the trick. @m-schmoock is that command meant for the lightningd start up flags?

m-schmoock commented 5 years ago

@Coinomatron When you have the sources of c-lightningd and compiled it, the thing you installed with pip is already on your harddrive (./contrib/pylightning). You can tell python to use this with the PYTHONPATH evnironment variable. pip makes sure a pylightning version is in your PYTHONPATH, but it may be a different version.

Writing the environment variable before the command actually sets the variable for the next command only, kind of a startup flag if you want :D

Coinomatron commented 5 years ago

Yes, I figured that much. I'd rather have done that, but I couldn't figure out this line.

PYTHONPATH=/home/user/lnrepo/contrib/pythonpath:$PYTHONPATH /hoe/user/lnrepo/lightningd/lightningd --plugin=...

In my case, that would be

PYTHONPATH=/home/user/lightning/contrib/pylightning:$PYTHONPATH /home/user/lightning/contrib/pylightning

?

m-schmoock commented 5 years ago

@Coinomatron For your example paths this would be:

PYTHONPATH=/home/user/lightning/contrib/pylightning:$PYTHONPATH /home/user/lightning/lightningd/lightningd --plugin=...