tinytuya icon indicating copy to clipboard operation
tinytuya copied to clipboard

Tinytuya unable to import due to outdated openSSL

Open Frefdt opened this issue 2 years ago • 7 comments

image

Frefdt avatar Jul 04 '23 16:07 Frefdt

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 your python environment has OpenSSL 1.1.0.

Workaround:

# remove urllib3 v2
pip uninstall urllib3
 
# install older version that support openssl v1.1.0
pip install urllib3==1.26.5 

I need to research if there is a good way we can address this. Since urllib3's decision to remove support for OpenSSL < 1.1.1, many other projects are impacted due to the transitive dependencies in python modules.

Any suggestions or PRs appreciated. 😁

jasonacox avatar Jul 04 '23 17:07 jasonacox

While it won't fix it, perhaps we should wrap that import in a try/except and print a message if it fails. That would at least allow local control to keep working.

uzlonewolf avatar Jul 04 '23 17:07 uzlonewolf

Ooooh! That's a great idea. I wonder if this would work...

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]))

@Frefdt can you try this (just paste into a python prompt)? Also, what OS are you using?

jasonacox avatar Jul 04 '23 18:07 jasonacox

image Yeah, seems like it works! Currently running windows 10, but being that this was a fresh install of both python 3.7 and vscode its probably for the best if you wrap it in there for others that encounter similar problems

Frefdt avatar Jul 04 '23 18:07 Frefdt

Also workaround worked just fine, thank you for the quick responses :)

Frefdt avatar Jul 04 '23 18:07 Frefdt

Thanks @Frefdt !

@uzlonewolf I thought about folding this into #370 but don't want to conflate it - I think we make this a minor patch (v1.12.9).

jasonacox avatar Jul 04 '23 19:07 jasonacox

Sounds like the best idea- just tested on a fresh vm and had the same issue so don't think it's an issue with my config specifically

Frefdt avatar Jul 04 '23 21:07 Frefdt