Pyinstaller created executable failing in _build_ssl_context (shotgun_api3\lib\httplib2\python3\

I’ve created a small, standalone python tool with a user interface window created in PyQT (PySide2 module).

I’m using pyinstaller to create a standalone executable, but whenever I try to run the executable I get this traceback (below).

Traceback (most recent call last):
  File "", line 38, in <module>
    class SGInteract():
  File "", line 54, in SGInteract
    sg = shotgun_api3.Shotgun(sgURL, login=sgLogin, password=sgPass)
  File "shotgun_api3\", line 677, in __init__
  File "shotgun_api3\", line 721, in server_caps
  File "shotgun_api3\", line 776, in info
  File "shotgun_api3\", line 3232, in _call_rpc
  File "shotgun_api3\", line 3372, in _make_call
  File "shotgun_api3\", line 3426, in _http_request
  File "shotgun_api3\lib\httplib2\python3\", line 1763, in request
  File "shotgun_api3\lib\httplib2\python3\", line 1239, in __init__
  File "shotgun_api3\lib\httplib2\python3\", line 194, in _build_ssl_context
FileNotFoundError: [Errno 2] No such file or directory

This is the code at that location in the Shotgun API code:

def _build_ssl_context(
    disable_ssl_certificate_validation, ca_certs, cert_file=None, key_file=None,
    maximum_version=None, minimum_version=None, key_password=None,
    if not hasattr(ssl, "SSLContext"):
        raise RuntimeError("httplib2 requires Python 3.2+ for ssl.SSLContext")
    context = ssl.SSLContext(DEFAULT_TLS_VERSION)
    context.verify_mode = (
        ssl.CERT_NONE if disable_ssl_certificate_validation else ssl.CERT_REQUIRED
    # SSLContext.maximum_version and SSLContext.minimum_version are python 3.7+.
    # source:
    if maximum_version is not None:
        if hasattr(context, "maximum_version"):
            context.maximum_version = getattr(ssl.TLSVersion, maximum_version)

This happens whether I use the “One Directory” (–onedir) or the “One File” (–onefile) options.
These are the commands I’ve used:

pyinstaller --onedir --windowed --hiddenimport xmlrpc  --hiddenimport xmlrpc.client --debug all -y
pyinstaller --onefile --windowed --hiddenimport xmlrpc  --hiddenimport xmlrpc.client --debug all -y

Is it that it can’t find the path to the stored SSL Certificates?


line 194 of that module is a blank line immediately following this:

context.verify_mode = (
    ssl.CERT_NONE if disable_ssl_certificate_validation else ssl.CERT_REQUIRED


I am having the same issue/error message trying to create a standalone executable with pyinstaller. Did you get anywhere with this problem?