rustyrussell / secp256k1-py

Python FFI bindings for libsecp256k1 (maintained)
MIT License
58 stars 13 forks source link

undefined symbol: secp256k1_keypair_xonly_pub #5

Open yuvadm opened 2 years ago

yuvadm commented 2 years ago

Installed the library in a plain new venv running on Arch Linux with Python 3.10, gmp 6.2.1 and libffi 3.4.2 - build seems fine:

(venv) $ pip install --no-cache-dir secp256k1
Collecting secp256k1
  Downloading secp256k1-0.14.0.tar.gz (2.4 MB)
     |████████████████████████████████| 2.4 MB 799 kB/s 
Collecting cffi>=1.3.0
  Downloading cffi-1.15.0-cp310-cp310-manylinux_2_12_x86_64.manylinux2010_x86_64.whl (446 kB)
     |████████████████████████████████| 446 kB 7.2 MB/s 
Collecting pycparser
  Downloading pycparser-2.21-py2.py3-none-any.whl (118 kB)
     |████████████████████████████████| 118 kB 7.9 MB/s 
Using legacy 'setup.py install' for secp256k1, since package 'wheel' is not installed.
Installing collected packages: pycparser, cffi, secp256k1
    Running setup.py install for secp256k1 ... done
Successfully installed cffi-1.15.0 pycparser-2.21 secp256k1-0.14.0

But on invocation getting this:

(venv) $ python -m secp256k1 privkey -p
Traceback (most recent call last):
  File "/usr/lib/python3.10/runpy.py", line 187, in _run_module_as_main
    mod_name, mod_spec, code = _get_module_details(mod_name, _Error)
  File "/usr/lib/python3.10/runpy.py", line 146, in _get_module_details
    return _get_module_details(pkg_main_name, error)
  File "/usr/lib/python3.10/runpy.py", line 110, in _get_module_details
    __import__(pkg_name)
  File "/tmp/bug/venv/lib/python3.10/site-packages/secp256k1/__init__.py", line 5, in <module>
    from ._libsecp256k1 import ffi, lib
ImportError: /tmp/bug/venv/lib/python3.10/site-packages/secp256k1/_libsecp256k1.cpython-310-x86_64-linux-gnu.so: undefined symbol: secp256k1_keypair_xonly_pub

Any ideas where the linkage error is coming from?

shafemtol commented 1 year ago

I had the same problem, though it was complaining about a different symbol:

ImportError: [...]/.local/lib/python3.11/site-packages/secp256k1/_libsecp256k1.cpython-311-x86_64-linux-gnu.so: undefined symbol: secp256k1_nonce_function_bip340

Turns out the system package libsecp256k1-devel was interfering. It worked after I removed that package and reinstalled the Python package:

sudo dnf remove libsecp256k1-devel
pip uninstall secp256k1
pip install --no-cache-dir secp256k1
nikicat commented 1 year ago

I had the same problem with the secp256k1_keypair_xonly_pub symbol and removing system package helps. Interesting why is it interfere with a system package?