toncenter / pytonlib

Python SDK for TON via tonlib
GNU General Public License v3.0
80 stars 21 forks source link

The first example from the documentation leads to an error. RuntimeError: Error in tonlibjson.__del__: 'TonLib' object has no attribute '_tonlib_json_client_destroy' #63

Open QuisEgoSum opened 3 months ago

QuisEgoSum commented 3 months ago

pytonlib 0.0.63 python 3.11

import requests
import asyncio
from pathlib import Path

from pytonlib import TonlibClient

async def main():
    # downloading mainnet config
    ton_config = requests.get('https://ton.org/global.config.json').json()

    # create keystore directory for tonlib
    keystore_dir = '/tmp/ton_keystore'
    Path(keystore_dir).mkdir(parents=True, exist_ok=True)

    # init TonlibClient
    client = TonlibClient(ls_index=0,  # choose LiteServer index to connect
                          config=ton_config,
                          keystore=keystore_dir)

    # init tonlibjson
    await client.init()

if __name__ == '__main__':
    asyncio.run(main())
Traceback (most recent call last):
  File "<rootPath>/main.py", line 26, in <module>
    asyncio.run(main())
  File "/usr/lib/python3.11/asyncio/runners.py", line 190, in run
    return runner.run(main)
           ^^^^^^^^^^^^^^^^
  File "/usr/lib/python3.11/asyncio/runners.py", line 118, in run
    return self._loop.run_until_complete(task)
           ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/usr/lib/python3.11/asyncio/base_events.py", line 654, in run_until_complete
    return future.result()
           ^^^^^^^^^^^^^^^
  File "<rootPath>/main.py", line 22, in main
    await client.init()
  File "<rootPath>/.venv/lib/python3.11/site-packages/pytonlib/client.py", line 71, in init
    wrapper = TonLib(event_loop, self.ls_index, self.cdll_path, self.verbosity_level)
              ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "<rootPath>/.venv/lib/python3.11/site-packages/pytonlib/tonlibjson.py", line 81, in __init__
    tonlib = CDLL(cdll_path)
             ^^^^^^^^^^^^^^^
  File "/usr/lib/python3.11/ctypes/__init__.py", line 376, in __init__
    self._handle = _dlopen(self._name, mode)
                   ^^^^^^^^^^^^^^^^^^^^^^^^^
OSError: libsecp256k1.so.0: cannot open shared object file: No such file or directory
Exception in tonlibjson.__del__: Traceback (most recent call last):
  File "<rootPath>/.venv/lib/python3.11/site-packages/pytonlib/tonlibjson.py", line 133, in __del__
    self._tonlib_json_client_destroy(self._client)
    ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
AttributeError: 'TonLib' object has no attribute '_tonlib_json_client_destroy'

Exception ignored in: <function TonLib.__del__ at 0x7f50ba77cd60>
Traceback (most recent call last):
  File "<rootPath>/.venv/lib/python3.11/site-packages/pytonlib/tonlibjson.py", line 136, in __del__
RuntimeError: Error in tonlibjson.__del__: 'TonLib' object has no attribute '_tonlib_json_client_destroy'
Morrigan-Ship commented 3 months ago

same ubuntu 24

complicat9d commented 2 months ago

same ubuntu 24

Had the same issue, while deploying my application on a Ubuntu 22.04 server. To ensure that pytonlib works, you have to make sure you are using SSL 1.1.1. The first comment in this problem says how to install it.

For reference: it is stated in one of the pytonlib dev's videos in the comments, so you might as well find something helpful there.

Morrigan-Ship commented 2 months ago

thank you

exaho commented 2 months ago

same on windows 11