jasonacox / tinytuya

Python API for Tuya WiFi smart devices using a direct local area network (LAN) connection or the cloud (TuyaCloud API).
MIT License
879 stars 159 forks source link

Handle import issue with urllib3 #377 #379

Closed jasonacox closed 1 year ago

jasonacox commented 1 year ago

User @Frefdt reported import error in https://github.com/jasonacox/tinytuya/issues/377:

image

ImportError: urllib3 v2.0 only supports OpenSSL 1.1.1+, currently the "ssl’ module is compiled with ‘OpenSSL 1.1.0h 27 Mar 2018". See: https://github.com/urllib3/urllib3/issues/2168

TinyTuya uses the requests library which uses urllib3. It seems that v2 of urllib3 now requires OpenSSL 1.1.1 but some python environments only have OpenSSL 1.1.0. This PR updates the import requests of TinyTuya to gracefully handle this error.

try:
    import requests
except ImportError as impErr:
    print("WARN: Unable to import requests library, Cloud functions will not work.")
    print("WARN: Check dependencies. See https://github.com/jasonacox/tinytuya/issues/377")
    print("WARN: Error: {}.".format(impErr.args[0]))