CryptographyDeprecationWarning: Python 3.6 is no longer supported by the Python core team

Question:

I upgraded my system from python 2 to python 3, and now when I run my code:

from cryptography.hazmat.backends import default_backend

I am getting this error

/usr/local/lib/python3.6/site-packages/paramiko/transport.py:33:
CryptographyDeprecationWarning: Python 3.6 is no longer supported by the Python 
core team. Therefore, support for it is deprecated in cryptography and will be 
removed in a future release.

How to resolve it?

Asked By: Kanhaiya Singh

||

Answers:

I ran into this issue today and did some digging. Since the os is not provided I think you could consider one of the options below:

  1. Upgrade your python version. This might be the best option since python 3.6 reached its EOL.

  2. You might be using SSH in your code. Consider installing an older version of paramiko.

  3. You can suppress the warning with these lines of code before importing Paramiko:

    import warnings 
    warnings.filterwarnings(action='ignore',module='.*paramiko.*')
    

or If you want to be more selective about suppressing JUST that particular deprecation warning:

import warnings
from cryptography.utils import CryptographyDeprecationWarning
warnings.filterwarnings("ignore", category=CryptographyDeprecationWarning)

source for option 3

  1. Check if you installed it using pip when you needed to use conda.
Answered By: Luv_Python

One of the solutions here suggests using

from cryptography.utils import CryptographyDeprecationWarning

That didn’t work in my case, since importing the warning object caused the warning itself as well.

Although it’s not an elegant solution (since "elegant" would be to upgrade Python), the following worked for me instead:

warnings.filterwarnings(action='ignore',message='Python 3.6 is no longer supported')
Answered By: 01drich

on ubuntu

sudo apt-get upgrade docker-compose

docker-compose must be 2.X
after that you need to refer old command to new command so do this

alias docker-compose='docker compose'
Answered By: Ali Bildir