Forums

Damaged pip?

I think I might have damaged my pip installation. Even on a simple pip3.8 list it yields an error ending with:

$ pip3.8 list
Traceback (most recent call last):
  File "/usr/local/bin/pip3.8", line 8, in <module>
    sys.exit(main())
  File "/usr/lib/python3.8/site-packages/pip/_internal/main.py", line 45, in main
    command = create_command(cmd_name, isolated=("--isolated" in cmd_args))
   File "/usr/lib/python3.8/site-packages/pip/_internal/commands/__init__.py", line 96, in create_command
    module = importlib.import_module(module_path)
  File "/usr/lib/python3.8/importlib/__init__.py", line 127, in import_module
    return _bootstrap._gcd_import(name[level:], package, level)
  File "<frozen importlib._bootstrap>", line 1014, in _gcd_import
  File "<frozen importlib._bootstrap>", line 991, in _find_and_load
  File "<frozen importlib._bootstrap>", line 975, in _find_and_load_unlocked
  File "<frozen importlib._bootstrap>", line 671, in _load_unlocked
  File "<frozen importlib._bootstrap_external>", line 783, in exec_module
  File "<frozen importlib._bootstrap>", line 219, in _call_with_frames_removed
  File "/usr/lib/python3.8/site-packages/pip/_internal/commands/list.py", line 13, in <module>
    from pip._internal.cli.req_command import IndexGroupCommand
  File "/usr/lib/python3.8/site-packages/pip/_internal/cli/req_command.py", line 20, in <module>
    from pip._internal.network.session import PipSession
  File "/usr/lib/python3.8/site-packages/pip/_internal/network/session.py", line 17, in <module>
    from pip._vendor import requests, six, urllib3
  File "/usr/lib/python3.8/site-packages/pip/_vendor/requests/__init__.py", line 97, in <module>
    from pip._vendor.urllib3.contrib import pyopenssl
  File "/usr/lib/python3.8/site-packages/pip/_vendor/urllib3/contrib/pyopenssl.py", line 46, in <module>
    import OpenSSL.SSL
  File "/usr/lib/python3.8/site-packages/OpenSSL/__init__.py", line 8, in <module>
    from OpenSSL import crypto, SSL
  File "/usr/lib/python3.8/site-packages/OpenSSL/crypto.py", line 1553, in <module>
    class X509StoreFlags(object):
  File "/usr/lib/python3.8/site-packages/OpenSSL/crypto.py", line 1573, in X509StoreFlags
    CB_ISSUER_CHECK = _lib.X509_V_FLAG_CB_ISSUER_CHECK
AttributeError: module 'lib' has no attribute 'X509_V_FLAG_CB_ISSUER_CHECK'

For installing new packages it gives me the same error as well. I'm trying to integrate Auth0 authentication with Flask. For what it's worth, I tried installing the following requirements:

flask>=2.0.3
python-dotenv>=0.19.2
authlib>=1.0
requests>=2.27.1

Any clues on how to fix this, and install the proper dependencies for the example code I'm following?

Looks like that's an issue between the pyOpenSSL and cryptography libraries - https://github.com/pyca/pyopenssl/issues/1143

If you delete ~/.local/lib/python3.8/site-packages and reinstall everything you had installed with pip --user, just make sure that you pin cryptography<38.0.0 in your requirements.