CryptographyDeprecationWarning: Python 2 wird vom Python-Kernteam nicht mehr unterstützt

Sep 09 2020

Ich versuche zu laufen docker-compose(was über installiert wurde pip), aber es tritt folgender Fehler auf:

# 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
# 

Gibt es eine Möglichkeit, docker-composedie Verwendung von Python3 anstelle von python( python2) zu erzwingen ?


@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
------------------------------
# 

Antworten

7 Ash Sep 09 2020 at 09:40

Dies ist das Problem der neuesten Version (0.17.0) von pyrsistent.

Sie sollten die frühere Version installieren.

pip uninstall pyrsistent
pip install pyrsistent==0.16.0
3 Micromegas Sep 09 2020 at 04:47

Ich weiß nicht, ob dies Ihr Problem beheben wird, aber ich hoffe, es kann Ihnen bei der Fehlerbehebung helfen. Ich hatte das gleiche Problem, aber ich war es leid, pip install docker-composein meinem Gitlab CI zu laufen .

Meine vorherigen Konfigurationen, bei denen das Problem auftrat, waren folgende:

    - apk update
    - apk upgrade
    - apk add python python-dev py-pip build-base libffi-dev openssl-dev libgcc
    - pip install docker-compose

Was es für mich behoben hat, war Folgendes:

    - apk update
    - apk upgrade
    - apk add build-base libffi-dev openssl-dev libgcc
    - apk add python3
    - apk add python3-dev
    - apk add py3-pip
    - pip3 install docker-compose

Der Kommentar von @ MikaelH ist also genau richtig. Versuchen Sie, auf pip3 zu aktualisieren, und stellen Sie sicher, dass Sie die erforderlichen Abhängigkeiten installiert haben. Das hängt von Ihrer Umgebung / Ihrem System ab. Wenn Sie auf Debian sind, können Sie verwenden sudo apt-get install python3, sudo apt-get install python3-pipund sudo apt-get install python3-dev libffi-dev libssl-devetc ...

2 daiwai Sep 11 2020 at 18:31

Da Python 2 nun nicht mehr verfügbar ist, sollte die Python 3-Version von pip verwendet werden, um Docker-Compose zu installieren. Unter Debian oder Ubuntu kann es installiert werden mit:

apt-get install python3-pip

Anschließend kann Docker Compose mit der Python 3-Pip-Version installiert werden

pip3 install docker-compose