Code that we have been running under Python 3.{9,10,11,12} has been working fine. Recently, something changed where Python 3.12 (and none of the other versions) began to fail with:
Traceback (most recent call last):
File "<string>", line 1, in <module>
File "/home/aliyun/aliyun-openapi-python-sdk/aliyun-python-sdk-core-v3/aliyunsdkcore/client.py", line 31, in <module>
from aliyunsdkcore.vendored.six.moves.urllib.parse import urlencode
ModuleNotFoundError: No module named 'aliyunsdkcore.vendored.six.moves'
The issue appears to be the version of six that is included in aliyunsdkcore/vendored/six.py and aliyunsdkcore/vendored/requests/packages/urllib3/packages/six.py is causing the issue.
A simple reproducer is to just import aliyunsdkcore.client.
(venv_py312) $ python -c "import aliyunsdkcore.client"
Traceback (most recent call last):
File "<string>", line 1, in <module>
File "/home/aliyun/aliyun-openapi-python-sdk/aliyun-python-sdk-core-v3/aliyunsdkcore/client.py", line 32, in <module>
from aliyunsdkcore.vendored.requests import codes
File "/home/aliyun/aliyun-openapi-python-sdk/aliyun-python-sdk-core-v3/aliyunsdkcore/vendored/requests/__init__.py", line 54, in <module>
from . import utils
File "/home/aliyun/aliyun-openapi-python-sdk/aliyun-python-sdk-core-v3/aliyunsdkcore/vendored/requests/utils.py", line 23, in <module>
from . import certs
File "/home/aliyun/aliyun-openapi-python-sdk/aliyun-python-sdk-core-v3/aliyunsdkcore/vendored/requests/certs.py", line 17, in <module>
from .packages.certifi import where
File "/home/aliyun/aliyun-openapi-python-sdk/aliyun-python-sdk-core-v3/aliyunsdkcore/vendored/requests/packages/__init__.py", line 3, in <module>
from . import urllib3
File "/home/aliyun/aliyun-openapi-python-sdk/aliyun-python-sdk-core-v3/aliyunsdkcore/vendored/requests/packages/urllib3/__init__.py", line 8, in <module>
from .connectionpool import (
File "/home/aliyun/aliyun-openapi-python-sdk/aliyun-python-sdk-core-v3/aliyunsdkcore/vendored/requests/packages/urllib3/connectionpool.py", line 11, in <module>
from .exceptions import (
File "/home/aliyun/aliyun-openapi-python-sdk/aliyun-python-sdk-core-v3/aliyunsdkcore/vendored/requests/packages/urllib3/exceptions.py", line 2, in <module>
from .packages.six.moves.http_client import (
ModuleNotFoundError: No module named 'aliyunsdkcore.vendored.requests.packages.urllib3.packages.six.moves'
(venv_py312) $ echo $?
1
We can then check the version of six that is installed and replace the vendored version:
Note, I believe the better course of action is to actually update the requests package instead of just changing the bundled six package in it, but this was a quick way of exhibiting the problem.
Code that we have been running under Python 3.{9,10,11,12} has been working fine. Recently, something changed where Python 3.12 (and none of the other versions) began to fail with:
The issue appears to be the version of six that is included in
aliyunsdkcore/vendored/six.py
andaliyunsdkcore/vendored/requests/packages/urllib3/packages/six.py
is causing the issue.A simple reproducer is to just
import aliyunsdkcore.client
.Here shows how it works with Python 3.11.4:
Now, when we do the same thing with Python 3.12.0b3:
We can then check the version of six that is installed, install a new version, and replace the vendored version:
If we try the same import again, we get:
We can then check the version of six that is installed and replace the vendored version:
Now, if we try again, it works:
Note, I believe the better course of action is to actually update the requests package instead of just changing the bundled six package in it, but this was a quick way of exhibiting the problem.