CryptographyDeprecationWarning:python 2不再被python核心团队支持

分享于 

5分钟阅读

互联网

  繁體

问题:

我尝试运行docker-compose(通过pip安装),但遇到以下错误:


# 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


# 



有没有办法强制docker-compose使用python3而不是python(python2)?


# 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


------------------------------


# 




答案1:

这是pyristent的最新版本(0.17.0)的问题。

你应该安装旧版本。


pip uninstall pyrsistent


pip install pyrsistent==0.16.0




答案2:

我有同样的问题,在gitlab CI中运行pip install docker-compose有问题。

发生问题的地方是:


 - apk update


 - apk upgrade


 - apk add python python-dev py-pip build-base libffi-dev openssl-dev libgcc


 - pip install docker-compose



修复它:


 - 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



尝试更新到pip3,并确保已安装必要的依赖项,如果在Debian上,你可以使用sudo apt-get install python3sudo apt-get install python3-pipsudo apt-get install python3-dev libffi-dev libssl-dev 等。


答案3

在Debian或Ubuntu上,可以安装:


apt-get install python3-pip



之后,python 3pip版本可用于安装Docker Compose


pip3 install docker-compose





SUP  CORE  long  Crypt  crypto  team