fantastic now works
thanks.
is there more elegant way to solve this?
yes there is. I have written a patch that allows you to import iceland's secp256k1 module from
any folder
==>
PATCH <==
You can get the patch or clone the patched version from
my git repository.
Without the patch, it would be necessary to change to the directory where iceland's secp256k1 files are located. Then you would run Python console with "python" or "python3" and import the module with:
import secp256k1 as ice
this only works because in the current working directory the file "
secp256k1.py" exists and also the required shared library "
ice_secp256k1.so" is located there. If you would try to start the Python console from another directory and load the module, it would fail with an error as you already noticed.
With the patch you can do it from any working directory, it doesn't matter then which is your working directory. The module will always find its required shared library "
ice_secp256k1.so".
Additional note:Since many users use
both the
standard Python module secp256k1 as well as
iceland2k14/secp256k1 I would personally recommend renaming iceland's module to e.g. ice_secp256k1. Because the two modules are different. This will prevent you from shadowing the other module when importing one of the two modules.
I myself have placed all 3rd party python modules in
~/foo/python/modulesIceland's secp256k1 module is located in
~/foo/python/modules/
ice_secp256k1To allow Python to search for modules in ~/foo/python/modules you can use the
PYTHONPATH environment variable:
export PYTHONPATH=$PYTHONPATH:/home/citb0in/foo/python/modules
As you do not want to do this on each system start or terminal start it is suggested to add the export command mentioned above in your ~/.bashrc so it is executed each time you login or start a new terminal. You can ensure that everything is correct by
echo $PYTHONPATH
Whenever I need iceland's secp256k1 module, I import it like that:
python3
Python 3.10.6 (main, Nov 14 2022, 16:10:14) [GCC 11.3.0] on linux
Type "help", "copyright", "credits" or "license" for more information.
>>> from ice_secp256k1 import secp256k1 as ice
>>> ice.privatekey_to_address(0, True, 123)
'141fTonryMQxmkKcba9FstmyQv3tqdBzTY'
>>>
Whenever I need Python's standard module "secp256k1" I just ue
import secp256k1
This way you can clearly distinguish between the two modules with the same name and you do not run the risk of confusion and problems.