本文记录在日常使用过程中遇到的Python问题
一,阿里云sts使用python授权访问
1,报错ImportError: cannot import name UnrewindableBodyError
Traceback (most recent call last):
File "privilage.py", line 6, in
import oss2
File "/usr/lib/python2.7/site-packages/oss2/__init__.py", line 3, in
from . import models, exceptions, defaults
File "/usr/lib/python2.7/site-packages/oss2/models.py", line 13, in
from .select_response import SelectResponseAdapter
File "/usr/lib/python2.7/site-packages/oss2/select_response.py", line 3, in
import requests
File "/usr/lib/python2.7/site-packages/requests/__init__.py", line 58, in
from . import utils
File "/usr/lib/python2.7/site-packages/requests/utils.py", line 32, in
from .exceptions import InvalidURL
File "/usr/lib/python2.7/site-packages/requests/exceptions.py", line 10, in
from urllib3.exceptions import HTTPError as BaseHTTPError
File "/usr/lib/python2.7/site-packages/urllib3/__init__.py", line 10, in
from .connectionpool import (
File "/usr/lib/python2.7/site-packages/urllib3/connectionpool.py", line 31, in
from .connection import (
File "/usr/lib/python2.7/site-packages/urllib3/connection.py", line 45, in
from .util.ssl_ import (
File "/usr/lib/python2.7/site-packages/urllib3/util/__init__.py", line 4, in
from .request import make_headers
File "/usr/lib/python2.7/site-packages/urllib3/util/request.py", line 5, in
from ..exceptions import UnrewindableBodyError
ImportError: cannot import name UnrewindableBodyError
解决:1),查看包安装
pip list|egrep 'requests|utils|urllib3'
DEPRECATION: The default format will switch to columns in the future. You can use --format=(legacy|columns) (or define a format=(legacy|columns) in your pip.conf under the [list] section) to disable this warning.
policycoreutils-default-encoding (0.1)
requests (2.18.4)
schedutils (0.4)
urllib3 (1.22)
2),更新urllib3版本
pip install --upgrade urllib3
Collecting urllib3
Downloading http://mirrors.aliyun.com/pypi/packages/e1/e5/df302e8017440f111c11cc41a6b432838672f5a70aa29227bf58149dc72f/urllib3-1.25.9-py2.py3-none-any.whl (126kB)
100% |████████████████████████████████| 133kB 4.6MB/s
Installing collected packages: urllib3
Found existing installation: urllib3 1.22
Uninstalling urllib3-1.22:
Successfully uninstalled urllib3-1.22
Successfully installed urllib3-1.25.9
pip list|egrep 'requests|utils|urllib3'
DEPRECATION: The default format will switch to columns in the future. You can use --format=(legacy|columns) (or define a format=(legacy|columns) in your pip.conf under the [list] section) to disable this warning.
policycoreutils-default-encoding (0.1)
requests (2.18.4)
schedutils (0.4)
urllib3 (1.25.9)
参考:https://help.aliyun.com/document_detail/32033.html?spm=a2c4g.11186623.6.922.56c61c62sz9hO0
https://github.com/aliyun/aliyun-oss-python-sdk/blob/master/examples/sts.py?spm=a2c4g.11186623.2.11.4fd62324jcMCM0&file=sts.py