electrum: "ModuleNotFoundError: No module named 'btchip'", however, it also won't let me install 'btchip'

Environment: Ubuntu 24.04, Electrum 4.5.8

Full error message:


File "/home/computer/.local/lib/python3.12/site-packages/electrum/plugins/ledger/ledger.py", line 42, in <module>
    from btchip.btchipComm import HIDDongleHIDAPI
ModuleNotFoundError: No module named 'btchip'
  9.41 | W | plugins.ledger.qt.Plugin | Library version for 'ledger' is incompatible.
Installed: 0.3.0, Needed: 0.2.0 <= x < 0.4.0

It won’t also let me install btchip:


python3 -m pip install btchip-python
Defaulting to user installation because normal site-packages is not writeable
Collecting btchip-python
  Using cached btchip-python-0.1.32.tar.gz (20 kB)
  Preparing metadata (setup.py) ... error
  error: subprocess-exited-with-error
  
  × python setup.py egg_info did not run successfully.
  │ exit code: 1
  ╰─> [1 lines of output]
      error in btchip-python setup command: 'extras_require' must be a dictionary whose values are strings or lists of strings containing valid project/version requirement specifiers.
      [end of output]
  
  note: This error originates from a subprocess, and is likely not a problem with pip.
error: metadata-generation-failed

× Encountered error while generating package metadata.
╰─> See above for output.

note: This is an issue with the package mentioned above, not pip.
hint: See above for details.

I have installed the following (as per https://github.com/spesmilo/electrum-docs/blob/master/hardware-linux.rst):

sudo apt-get install libusb-1.0-0-dev libudev-dev
python3 -m pip install hidapi ecdsa ledger-bitcoin  #(but it would not accept btchip-python)

apt show libudev-dev Package: libudev-dev Version: 255.4-1ubuntu8.4 Priority: optional Section: admin Source: systemd Origin: Ubuntu Maintainer: Ubuntu Developers ubuntu-devel-discuss@lists.ubuntu.com Original-Maintainer: Debian systemd Maintainers pkg-systemd-maintainers@lists.alioth.debian.org Bugs: https://bugs.launchpad.net/ubuntu/+filebug Installed-Size: 197 kB Depends: libudev1 (= 255.4-1ubuntu8.4) Homepage: https://www.freedesktop.org/wiki/Software/systemd Download-Size: 22.0 kB APT-Manual-Installed: yes APT-Sources: http://nz.archive.ubuntu.com/ubuntu noble-updates/main amd64 Packages Description: libudev development files This library provides APIs to introspect and enumerate devices on the local system. . This package contains the files needed for developing applications that use libudev.

N: There is 1 additional record. Please use the ‘-a’ switch to see it

apt show libusb-1.0-0-dev Package: libusb-1.0-0-dev Version: 2:1.0.27-1 Priority: optional Section: libdevel Source: libusb-1.0 Origin: Ubuntu Maintainer: Ubuntu Developers ubuntu-devel-discuss@lists.ubuntu.com Original-Maintainer: Aurelien Jarno aurel32@debian.org Bugs: https://bugs.launchpad.net/ubuntu/+filebug Installed-Size: 328 kB Depends: libusb-1.0-0 (= 2:1.0.27-1) Recommends: libusb-1.0-doc Homepage: http://www.libusb.info/ Download-Size: 77.7 kB APT-Manual-Installed: yes APT-Sources: http://nz.archive.ubuntu.com/ubuntu noble/main amd64 Packages Description: userspace USB programming library development files Library for programming USB applications without the knowledge of Linux kernel internals. . This package contains what you need for compiling sources that use this library in your own code.

pip show ecdsa Name: ecdsa Version: 0.19.0 Summary: ECDSA cryptographic signature library (pure python) Home-page: http://github.com/tlsfuzzer/python-ecdsa Author: Brian Warner Author-email: warner@lothar.com License: MIT Location: /home/computer/.local/lib/python3.12/site-packages Requires: six Required-by: trezor

pip show hidapi Name: hidapi Version: 0.14.0.post4 Summary: A Cython interface to the hidapi from https://github.com/libusb/hidapi Home-page: https://github.com/trezor/cython-hidapi Author: Pavol Rusnak Author-email: pavol@rusnak.io License: Location: /home/computer/.local/lib/python3.12/site-packages Requires: setuptools Required-by:

pip show ledger-bitcoin Name: ledger_bitcoin Version: 0.3.0 Summary: Client for Ledger Nano Bitcoin application Home-page: https://github.com/LedgerHQ/app-bitcoin-new Author: Ledger Author-email: hello@ledger.fr License: Location: /home/computer/.local/lib/python3.12/site-packages Requires: ledgercomm, packaging, typing-extensions Required-by:

pip show setuptools Name: setuptools Version: 75.6.0 Summary: Easily download, build, install, upgrade, and uninstall Python packages Home-page: Author: Author-email: Python Packaging Authority distutils-sig@python.org License: Location: /home/computer/.local/lib/python3.12/site-packages Requires: Required-by: hidapi

About this issue

  • Original URL
  • State: closed
  • Created 2 years ago
  • Reactions: 1
  • Comments: 16 (8 by maintainers)

Commits related to this issue

Most upvoted comments

We can either

But yeah, maybe easiest to drop support.

There has been a deprecation warning shown to users in the GUI for 2 years now: https://github.com/spesmilo/electrum/commit/9b82eb6d06f8534652849f3370ab8af7d7ca9c7f

As a temporary fix, this patch will allow pip to install btchip-python

diff --git a/setup.py b/setup.py
index accfe24..5ab305d 100644
--- a/setup.py
+++ b/setup.py
@@ -17,7 +17,7 @@ setup(
     packages=find_packages(),
     install_requires=['hidapi>=0.7.99', 'ecdsa>=0.9'],
     extras_require = {
-       'smartcard': [ 'python-pyscard>=1.6.12-4build1' ]
+       'smartcard': [ 'pyscard>=1.6.12' ]
     },
     include_package_data=True,
     zip_safe=False,

Wondering if anyone has thoughts on why an Ubuntu upgrade could have caused the error.

btchip-python is unmaintained and it uses syntax in its setup.py file that is no longer understood by modern setuptools. The new ubuntu version uses newer setuptools (python3-setuptools in apt), which can no longer parse that setup.py.

Can confirm that also on a completely clean Ubuntu 24.04 installation python3 -m pip install btchip-python produces the same error. I will close the issue, but it essentially means I am unable to use a ledger with electrum on a Ubuntu 24.04 installation.

What I am not sure about is that https://github.com/LedgerHQ/btchip-python has been archived on Oct 16, 2024 and is read-only, yet electrum is still requiring the btchip-python library. I will investigate with ledger further.