Failed to run Python3 application using OpenSSL on Linkit Smart 7688: symbol not found

An python(version 3.7.7) application installed in my device(MTK 7688 LinkIt) with openwrt 19.02, when I run a function, err occurred as below:

2020-05-21 12:40:03 ERROR (MainThread) [homeassistant.components.websocket_api.http.connection.49625456] Error relocating /usr/lib/python3.7/site-packages/cryptography/hazmat/bindings/_openssl.abi3.so: SSL_CTX_set_next_protos_advertised_cb: symbol not found
Traceback (most recent call last):
  File "/usr/lib/python3.7/site-packages/homeassistant/components/websocket_api/commands.py", line 130, in handle_call_service
    connection.context(msg),
  File "/usr/lib/python3.7/site-packages/homeassistant/core.py", line 1247, in async_call
    task.result()
  File "/usr/lib/python3.7/site-packages/homeassistant/core.py", line 1282, in _execute_service
    await handler.func(service_call)
  File "/usr/lib/python3.7/site-packages/homeassistant/helpers/entity_component.py", line 213, in handle_service
    self._platforms.values(), func, call, required_features
  File "/usr/lib/python3.7/site-packages/homeassistant/helpers/service.py", line 453, in entity_service_call
    future.result()  # pop exception if have
  File "/usr/lib/python3.7/site-packages/homeassistant/helpers/entity.py", line 596, in async_request_call
    await coro
  File "/usr/lib/python3.7/site-packages/homeassistant/helpers/service.py", line 484, in _handle_entity_call
    await result
  File "/usr/lib/python3.7/site-packages/homeassistant/components/light/__init__.py", line 244, in async_handle_light_on_service
    await light.async_turn_on(**params)
  File "/usr/lib/python3.7/site-packages/homeassistant/helpers/entity.py", line 621, in async_turn_on
    await self.hass.async_add_executor_job(ft.partial(self.turn_on, **kwargs))
  File "/usr/lib/python3.7/concurrent/futures/thread.py", line 57, in run
  File "/usr/lib/python3.7/site-packages/homeassistant/components/xiaomi_aqara/light.py", line 106, in turn_on
    if self._write_to_hub(self._sid, **{self._data_key: rgbhex}):
  File "/root/.homeassistant/deps/lib/python3.7/site-packages/xiaomi_gateway/__init__.py", line 346, in write_to_hub
    data['key'] = self._get_key()
  File "/root/.homeassistant/deps/lib/python3.7/site-packages/xiaomi_gateway/__init__.py", line 402, in _get_key
    backend=default_backend()).encryptor()
  File "/usr/lib/python3.7/site-packages/cryptography/hazmat/backends/__init__.py", line 15, in default_backend
    from cryptography.hazmat.backends.openssl.backend import backend
  File "/usr/lib/python3.7/site-packages/cryptography/hazmat/backends/openssl/__init__.py", line 7, in <module>
    from cryptography.hazmat.backends.openssl.backend import backend
  File "/usr/lib/python3.7/site-packages/cryptography/hazmat/backends/openssl/backend.py", line 75, in <module>
    from cryptography.hazmat.bindings.openssl import binding
  File "/usr/lib/python3.7/site-packages/cryptography/hazmat/bindings/openssl/binding.py", line 16, in <module>
    from cryptography.hazmat.bindings._openssl import ffi, lib
ImportError: Error relocating /usr/lib/python3.7/site-packages/cryptography/hazmat/bindings/_openssl.abi3.so: SSL_CTX_set_next_protos_advertised_cb: symbol not found

Any suggestion to fix it´╝čIt's been bothering me for days.

Here is information of my environment:

root@OpenWrt:/# python3 -V
Python 3.7.7

root@OpenWrt:/# openssl version
OpenSSL 1.1.1g  21 Apr 2020

root@OpenWrt:/# opkg info openssl-util
Package: openssl-util
Version: 1.1.1g-1
Depends: libc, libopenssl1.1, libopenssl-conf
Status: install user installed
Architecture: mipsel_24kc
Installed-Time: 1589965461

root@OpenWrt:/# ll /usr/lib/python3.7/site-packages/cryptography/hazmat/bindings
/openssl/binding.py
-rw-r--r--    1 root     root          7487 May 21 12:20 /usr/lib/python3.7/site-packages/cryptography/hazmat/bindings/openssl/binding.py

root@OpenWrt:/# pip show cryptography
Name: cryptography
Version: 2.9
Summary: cryptography is a package which provides cryptographic recipes and primitives to Python developers.
Home-page: https://github.com/pyca/cryptography
Author: The cryptography developers
Author-email: cryptography-dev@python.org
License: BSD or Apache License, Version 2.0
Location: /usr/lib/python3.7/site-packages
Requires: six, cffi
Required-by: pyOpenSSL, josepy, homeassistant, acme

root@OpenWrt:/# pip show cffi
Name: cffi
Version: 1.13.2
Summary: Foreign Function Interface for Python calling C code.
Home-page: http://cffi.readthedocs.org
Author: Armin Rigo, Maciej Fijalkowski
Author-email: python-cffi@googlegroups.com
License: MIT
Location: /usr/lib/python3.7/site-packages
Requires: pycparser
Required-by: cryptography, bcrypt

My solution for this error as follow:
make menuconfig

find keyword 'WITH_NPN'
and then enable this option >> save configuration and make again

new firmware works well to run python3 application :grinning:

This topic was automatically closed 10 days after the last reply. New replies are no longer allowed.