plugins icon indicating copy to clipboard operation
plugins copied to clipboard

backup.py: ModuleNotFoundError: No module named 'pyln.spec'

Open v4w5gse65g874 opened this issue 2 years ago • 6 comments

root@ubuntu:~# lightningd --encrypted-hsm
2021-12-04T16:51:03.763Z DEBUG   plugin-manager: started(18545) /usr/local/bin/../libexec/c-lightning/plugins/autoclean
2021-12-04T16:51:03.765Z DEBUG   plugin-manager: started(18546) /usr/local/bin/../libexec/c-lightning/plugins/bcli
2021-12-04T16:51:03.773Z DEBUG   plugin-manager: started(18547) /usr/local/bin/../libexec/c-lightning/plugins/fetchinvoice
2021-12-04T16:51:03.785Z DEBUG   plugin-manager: started(18548) /usr/local/bin/../libexec/c-lightning/plugins/funder
2021-12-04T16:51:03.792Z DEBUG   plugin-manager: started(18549) /usr/local/bin/../libexec/c-lightning/plugins/topology
2021-12-04T16:51:03.800Z DEBUG   plugin-manager: started(18550) /usr/local/bin/../libexec/c-lightning/plugins/keysend
2021-12-04T16:51:03.802Z DEBUG   plugin-manager: started(18551) /usr/local/bin/../libexec/c-lightning/plugins/offers
2021-12-04T16:51:03.818Z DEBUG   plugin-manager: started(18552) /usr/local/bin/../libexec/c-lightning/plugins/pay
2021-12-04T16:51:03.825Z DEBUG   plugin-manager: started(18553) /usr/local/bin/../libexec/c-lightning/plugins/txprepare
2021-12-04T16:51:03.834Z DEBUG   plugin-manager: started(18554) /usr/local/bin/../libexec/c-lightning/plugins/spenderp
2021-12-04T16:51:03.841Z DEBUG   plugin-manager: started(18555) /root/repos/plugins/backup/backup.py
Traceback (most recent call last):
  File "/root/repos/plugins/backup/backup.py", line 2, in <module>
    from pyln.client import Plugin
  File "/root/repos/lightning/contrib/pyln-client/pyln/client/__init__.py", line 3, in <module>
    from .gossmap import Gossmap, GossmapNode, GossmapChannel, GossmapNodeId
  File "/root/repos/lightning/contrib/pyln-client/pyln/client/gossmap.py", line 3, in <module>
    from pyln.spec.bolt7 import (channel_announcement, channel_update,
ModuleNotFoundError: No module named 'pyln.spec'
2021-12-04T16:51:04.035Z INFO    plugin-backup.py: Killing plugin: exited before replying to getmanifest

My installed versions/packages:

root@ubuntu:~# lightning-cli --version
v0.10.2
root@ubuntu:~# pip3 list | grep pyln
pyln-bolt7                    1.0.2.186
pyln-client                   0.9.3
pyln-proto                    0.10.1

I'm not sure what to do here; googling this brought up basically nothing.

v4w5gse65g874 avatar Dec 04 '21 16:12 v4w5gse65g874

Seems there is a missing dependency from pyln-proto to pyln-bolt7. Does installing that package solve this? If yes I'll fixup the requirements file.

cdecker avatar Dec 08 '21 12:12 cdecker

Thanks for the reply. Maybe I'm missing something, but what should I be installing? I have both pyln-proto and pyln-bolt7 installed.

Trying to install pyln-spec is failing...

root@ubuntu:~/repos/plugins/backup# pip3 install pyln-spec
ERROR: Could not find a version that satisfies the requirement pyln-spec (from versions: none)
ERROR: No matching distribution found for pyln-spec

I found this issue but the link to build from source is dead: https://github.com/ElementsProject/lightning/issues/3982

v4w5gse65g874 avatar Dec 09 '21 22:12 v4w5gse65g874

Traceback (most recent call last): File "/root/repos/plugins/backup/backup.py", line 2, in from pyln.client import Plugin File "/root/repos/lightning/contrib/pyln-client/pyln/client/init.py", line 3, in from .gossmap import Gossmap, GossmapNode, GossmapChannel, GossmapNodeId File "/root/repos/lightning/contrib/pyln-client/pyln/client/gossmap.py", line 3, in from pyln.spec.bolt7 import (channel_announcement, channel_update, ModuleNotFoundError: No module named 'pyln.spec'

@v4w5gse65g874 I was able to reproduce your error once ... but I also don't understand it.

The requirements.txt for backup plugin shows pyln-client ~= 0.9.2, no other pyln-x.

After uninstalling all pyln-x (including bolts) with python3 -m pip uninstall and then reinstall with python3 -m pip install -r requirements.txt

Then the plugin runs fine without above error and python3 -m pip list shows only pyln-client

SimonVrouwe avatar Dec 29 '21 16:12 SimonVrouwe

@SimonVrouwe you sir have pointed me in the correct direction. Thank you. Seriously, it really helped. After trying a couple of different things I kept seeing this error in my console:

  Attempting uninstall: pyln-client
    Found existing installation: pyln-client 0.10.2
    Can't uninstall 'pyln-client'. No files were found to uninstall.
Successfully installed pyln-client-0.9.3

But... the version was still 0.10.2. Running python3 -m pip show pyln-client finally showed me the installation location which was /root/repos/lightning/contrib/pyln-client - deleting that, then running python3 -m pip install -r requirements.txt in the plugins/backup directory finally installed the right pyln-client version.

Things are fine now, and I no longer have to worry about losing my channels suddenly.

v4w5gse65g874 avatar Dec 31 '21 00:12 v4w5gse65g874

@v4w5gse65g874 are you running Ubuntu by chance?

I recently tried a fresh install of Ubuntu because I thought things would go smoother, and from my experience the way they handle program paths is a complete mess. I would try updating pip and it would work and spit out the latest version, then when I went to check the version, it would give me an old version. I remember doing which pip and having it give me back a different location than the one pip was trying to update. I probably should have documented my experience better and submitted it as an issue to Ubuntu or Python, but I didn't have a github account at the time and I have since switched back to Arch out of frustration.

PestToast avatar Feb 13 '22 18:02 PestToast

This was also happening to me on rebalance and summary. Do some requirements files need to be updated? Or possibly some Python wheels? Just installing the requirements files didn't work for me:

pip install -r /usr/local/libexec/c-lightning/plugins/rebalance/requirements.txt ...resulted in this:

# pip freeze
pyln-client==0.10.2.post1

a subsequent pip install -r /usr/local/libexec/c-lightning/plugins/summary/requirements.txt ..resulted in this:

# pip freeze
certifi==2022.5.18.1
charset-normalizer==2.0.12
idna==3.3
packaging==21.3
pyln-client==0.10.2.post1
pyparsing==3.0.9
PySocks==1.7.1
requests==2.28.0
urllib3==1.26.9

Both plugins crashed until I ran: pip install -U pyln-proto pyln-bolt7

Not sure if pyln-proto is necessary, but pyln-bolt7 appears to be necessary, and missing from the requirements.txt files.

chrisguida avatar Jun 09 '22 23:06 chrisguida