Oracle Cloud 甲骨文云使用 API(OCI)提示 CryptographyDeprecationWarning 问题解决

小助手读文章 00:00 / 00:00

温馨提示:
本文所述内容具有依赖性,可能因软硬条件不同而与预期有所差异,故请以实际为准,仅供参考。

近期在 Oracle 云主机上使用 oci 命令,每次都出现提示:

/usr/local/oracle/lib/oracle-cli/lib/python3.6/site-packages/oci/_vendor/httpsig_cffi/sign.py:10: CryptographyDeprecationWarning: Python 3.6 is no longer supported by the Python core team. Therefore, support for it is deprecated in cryptography. The next release of cryptography (40.0) will be the last to support Python 3.6.
  from cryptography.hazmat.backends import default_backend  # noqa: F401

提示上写了很清楚了,Python 版本不够新,不过 oci 命令使用的 Python 版本是安装 oci 命令时自动安装的,因此去调整 Python 太麻烦。

所以我们使用了另外一个方法,把这个错误提示隐藏,因为这个提示本身没有任何意义。

依照提示,打开提示错误的文件,引入 warnings 模块,并屏蔽这条错误,如下:

root@oc-jp:~ # vim /usr/local/oracle/lib/oracle-cli/lib/python3.6/site-packages/oci/_vendor/httpsig_cffi/sign.py
...
import base64
import warnings
warnings.filterwarnings('ignore', message='.*cryptography', )
from oci._vendor import six
...

关键点:

import warnings
warnings.filterwarnings('ignore', message='.*cryptography', )

参考命令:

sed -i '7aimport warnings' /usr/local/oracle/lib/oracle-cli/lib/python3.6/site-packages/oci/_vendor/httpsig_cffi/sign.py
sed -i "8awarnings.filterwarnings('ignore', message='.*cryptography', )" /usr/local/oracle/lib/oracle-cli/lib/python3.6/site-packages/oci/_vendor/httpsig_cffi/sign.py

ArmxMod for Typecho
个性化、自适应、功能强大的响应式主题

推广

 继续浏览关于 VPS部署教程pythonapi解决方案oracle甲骨文oci云主机 的文章

 本文最后更新于 2024/01/25 21:02:09,可能因经年累月而与现状有所差异

 引用转载请注明: VirCloud's Blog > 经验 > Oracle Cloud 甲骨文云使用 API(OCI)提示 CryptographyDeprecationWarning 问题解决