Incompatible codecs in module "encodings.utf_8"

I wrote a Python package that I am using in Ignition. It works great. I have to add TLS to my communication, it no longer works. I get this error:

Caused by: org.python.core.PyException: encodings.CodecRegistryError: incompatible codecs in module "encodings.utf_8"

Is there a way to fix this or an I screwed?

I have an alternative method but it requires requests which, when imported throws this error:

Caused by: org.python.core.PyException: encodings.CodecRegistryError: incompatible codecs in module "encodings.hex_codec"

If anyone can help that would be greatly appreciated.

Use java's tools instead of jython. Python2 has horrible encoding support. Since jython runs in java, it can call java classes to perform network communication with encoding support. Look especially at system.net.httpClient(), which has modern TLS support.

(You can probably get the last python2.7 version of requests to work. Others have.)

This is a known thing with no real satisfactory "fix" beyond, as Phil said, avoiding Jython stdlib stuff. My hunch is that it's a Jython bug we'll have to diagnose and fix.

Ended up making an executable that does everything and just call that from Ignition. Feels like a hack but seems to work pretty good so far.

I wasn't using Jythons tools directly. I using a library that is compatible with both 2.7 and 3.10, but not Jython apparently.

I downloaded requests from here https://pypi.org/project/requests/2.7.0/ and it did not work.

Maybe some other time I'll look into trying to import the Java version of the library and see if I can make that work.