1

I'm getting this error:

/System/Library/Frameworks/Python.framework/Versions/2.7/Extras/lib/python/OpenSSL/crypto.py:14: CryptographyDeprecationWarning: Python 2 is no longer supported by the Python core team. Support for it is now deprecated in cryptography, and will be removed in the next release. from cryptography import utils, x509

I have tried updating the cryptography module and python. What is the solution to this problem?

chackerian
  • 1,301
  • 2
  • 15
  • 29
  • 1
    Upgrade to Python 3.x. – Barmar Jan 22 '22 at 00:20
  • 1
    Python 2 hasn't received a major update since 2010, and its last patch was in 2019. It was sunset at the start of 2020, and no longer receives security updates, so using cryptography modules with it may not be the best idea. I'd upgrade to Python 3 as soon as humanly possible if I were you. – Miguel Guthridge Jan 22 '22 at 00:41
  • 1
    If you are using Python 3, or you don't know the difference between them, try running your code using the `python3` command instead of just `python`. Your system may have `python` associated with `python2` instead of `python3`. – Miguel Guthridge Jan 22 '22 at 00:43
  • 1

1 Answers1

2

macOS Monterey ships /usr/bin/python as Python 2.7.18 along with a set of default packages. This Python is provided as a final fallback for compatibility with legacy software. When executing this Apple provided Python you will see the following initial message:

WARNING: Python 2.7 is not recommended. 
This version is included in macOS for compatibility with legacy software. 
Future versions of macOS will not include Python 2.7. 
Instead, it is recommended that you transition to using 'python3' from within Terminal.

Since they are shipping a set of packages that they have shipped for years, this includes cryptography, which also deprecated Python 2 support and began raising warnings about dropping support in version 3.3. Apple ships version 3.3.2, which is the final version of cryptography that supported Python 2.

The only true resolution to this is to stop using Python 2. You can install a newer Python from python.org, use tools like pyenv or conda, or use Apple's Python 3, but migration is required. And, of course, Apple will likely drop their py2 installation next year when macOS 13 is released.

Edit: Apple actually dropped Python 2 in macOS 12.3.

Paul Kehrer
  • 13,466
  • 4
  • 40
  • 57
  • Ok, when I use python 3 there are different problems so I didn't know what to do. I posted about the different error here: https://stackoverflow.com/questions/70809158/dyld-cache-system-library-dyld-dyld-shared-cache-x86-64h-not-loaded-syscall – chackerian Jan 22 '22 at 16:47