Python – CryptographyDeprecationWarning: Python 2 is no longer supported by the Python core team

docker-composepippython

I'm trying to run docker-compose (which was installed via pip), yet running into following error:

# pip install --quiet docker-compose
# docker-compose ps
/usr/local/lib/python2.7/dist-packages/paramiko/transport.py:33: 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 a future release.
  from cryptography.hazmat.backends import default_backend
Traceback (most recent call last):
  File "/usr/local/bin/docker-compose", line 7, in <module>
    from compose.cli.main import main
  File "/usr/local/lib/python2.7/dist-packages/compose/cli/main.py", line 24, in <module>
    from ..config import ConfigurationError
  File "/usr/local/lib/python2.7/dist-packages/compose/config/__init__.py", line 6, in <module>
    from .config import ConfigurationError
  File "/usr/local/lib/python2.7/dist-packages/compose/config/config.py", line 51, in <module>
    from .validation import match_named_volumes
  File "/usr/local/lib/python2.7/dist-packages/compose/config/validation.py", line 12, in <module>
    from jsonschema import Draft4Validator
  File "/usr/local/lib/python2.7/dist-packages/jsonschema/__init__.py", line 21, in <module>
    from jsonschema._types import TypeChecker
  File "/usr/local/lib/python2.7/dist-packages/jsonschema/_types.py", line 3, in <module>
    from pyrsistent import pmap
  File "/usr/local/lib/python2.7/dist-packages/pyrsistent/__init__.py", line 3, in <module>
    from pyrsistent._pmap import pmap, m, PMap
  File "/usr/local/lib/python2.7/dist-packages/pyrsistent/_pmap.py", line 98
    ) from e
         ^
SyntaxError: invalid syntax
# 

# cat /etc/debian_version 
9.13
# python2 --version
Python 2.7.13
# python3 --version
Python 3.5.3
# 

Is there a way to force docker-compose to use python3 instead of python (python2)?


@Micromegas / @MikaelH

# apt-get -q install python3-pip
# pip3 install --quiet docker-compose
# docker-compose ps
/usr/local/lib/python3.5/dist-packages/paramiko/transport.py:33: CryptographyDeprecationWarning: Python 3.5 support will be dropped in the next release ofcryptography. Please upgrade your Python.
  from cryptography.hazmat.backends import default_backend
Name   Command   State   Ports
------------------------------
# 

Best Answer

This is the issue of the latest version(0.17.0) of pyrsistent.

You should install the past version.

pip uninstall pyrsistent
pip install pyrsistent==0.16.0
Related Topic