If you get error like: AttributeError: module 'lib' has no attribute 'X509_V_FLAG_NOTIFY_POLICY' probably you're seeing this because of a version mismatch between two packages: cryptography and pyOpenSSL.

cryptography >= 42.0.0 removed the X509_V_FLAG_NOTIFY_POLICY flag. pyOpenSSL < 23.2.0 still tries to reference it. When they end up installed together, everything that touches OpenSSL breaks — including pip, conda, and any tool that imports pyOpenSSL at startup.

The fix

Upgrade pyOpenSSL to a version that no longer references the removed flag:

pip install "pyOpenSSL>=23.2.0"

If pip itself is broken by the error, install via python -m pip directly:

python -m pip install "pyOpenSSL>=23.2.0"

If you're using conda

conda install pyopenssl

Or force the correct version:

conda install "pyopenssl>=23.2.0"

Reason

Package Change
cryptography >= 42.0.0 Removed X509_V_FLAG_NOTIFY_POLICY from its C bindings
pyOpenSSL < 23.2.0 Still imports X509_V_FLAG_NOTIFY_POLICY at module load time

Any combination of cryptography >= 42 + pyOpenSSL < 23.2 will trigger the error.

source: Explanation

For folks curious about the breakage:

cryptography 42.0.0 removed this X509_V_FLAG_NOTIFY_POLICY flag: pyca/cryptography@654dccb
pyOpenSSL 23.2.0 stopped referencing this X509_V_FLAG_NOTIFY_POLICY flag: pyca/pyopenssl@d788a4f
So, you'll only run into this issue if you're running cryptography >= 42.0.0, and pyOpenSSL < 23.2.0

Python requirements

You can also update the requirements.txt file by:

cryptography >= 42.0.0
pyOpenSSL < 23.2.0

Alternative solutions

Belove you can find alternative solutions which were reported as useful:

python3 -m pip install pip --upgrade
pip install pyopenssl --upgrade

Source: AttributeError: module 'lib' has no attribute 'X509_V_FLAG_CB_ISSUER_CHECK'

Verify the fix

python -c "import OpenSSL; print(OpenSSL.__version__)"

If it prints a version without throwing, you're good.