Thank you Jeff, actually it is working if I execute the script locally.
I managed to solve by removing all the folders related to “otocore” from dqse/myenv/lib/python3.7/site-packages and by changing the dependencies list to:
dependencies = [
#"pyspark",
"python-dateutil>=2.8.2",
"pydantic==1.6.1",
"pandas",
"pyarrow==1.0.1",
"pymongo",
"sqlparse",
"scipy",
"scikit-learn",
"requests",
"urllib3<=1.26.15",
"pyod",
"xgboost",
"shap",
"ray",
"s3fs",
"boto3==1.33.13",
"botocore==1.33.13"
]
However, running the script with this new list of dependencies on my emr cluster (always Python 3.7), I am getting always the error:
ImportError: cannot import name ‘DEPRECATED_SERVICE_NAMES’ from ‘botocore.docs’
In this case I have noticed that I don’t have any warning related to “otocore”, but in the logs I have:
Requirement already satisfied: yarl<2.0,>=1.0 in /usr/local/lib64/python3.7/site-packages (from aiohttp!=4.0.0a0,!=4.0.0a1->s3fs) (1.9.4)
Collecting botocore<1.27.60,>=1.27.59
Using cached botocore-1.27.59-py3-none-any.whl (9.1 MB)
Requirement already satisfied: aioitertools>=0.5.1 in /usr/local/lib/python3.7/site-packages (from aiobotocore~=2.4.2->s3fs) (0.11.0)
Requirement already satisfied: wrapt>=1.10.10 in /usr/local/lib64/python3.7/site-packages (from aiobotocore~=2.4.2->s3fs) (1.16.0)
Requirement already satisfied: importlib-metadata; python_version < "3.8" in /usr/local/lib/python3.7/site-packages (from attrs>=17.3.0->aiohttp!=4.0.0a0,!=4.0.0a1->s3fs) (6.7.0)
Requirement already satisfied: idna>=2.0 in /usr/local/lib/python3.7/site-packages (from yarl<2.0,>=1.0->aiohttp!=4.0.0a0,!=4.0.0a1->s3fs) (3.10)
Requirement already satisfied: jmespath<2.0.0,>=0.7.1 in /usr/local/lib/python3.7/site-packages (from botocore<1.27.60,>=1.27.59->aiobotocore~=2.4.2->s3fs) (1.0.0)
Requirement already satisfied: urllib3<1.27,>=1.25.4 in /usr/local/lib/python3.7/site-packages (from botocore<1.27.60,>=1.27.59->aiobotocore~=2.4.2->s3fs) (1.26.15)
Requirement already satisfied: python-dateutil<3.0.0,>=2.1 in /usr/local/lib/python3.7/site-packages (from botocore<1.27.60,>=1.27.59->aiobotocore~=2.4.2->s3fs) (2.9.0.post0)
Requirement already satisfied: zipp>=0.5 in /usr/local/lib/python3.7/site-packages (from importlib-metadata; python_version < "3.8"->attrs>=17.3.0->aiohttp!=4.0.0a0,!=4.0.0a1->s3fs) (3.15.0)
Requirement already satisfied: six>=1.5 in /usr/local/lib/python3.7/site-packages (from python-dateutil<3.0.0,>=2.1->botocore<1.27.60,>=1.27.59->aiobotocore~=2.4.2->s3fs) (1.13.0)
Installing collected packages: botocore
Attempting uninstall: botocore
Found existing installation: botocore 1.33.13
Uninstalling botocore-1.33.13:
Successfully uninstalled botocore-1.33.13
ERROR: After October 2020 you may experience errors when installing or updating packages. This is because pip will change the way that it resolves dependency conflicts.
We recommend you use --use-feature=2020-resolver to test your packages with the new resolver before it becomes the default.
s3transfer 0.8.2 requires botocore<2.0a.0,>=1.33.2, but you'll have botocore 1.27.59 which is incompatible.
boto3 1.33.13 requires botocore<1.34.0,>=1.33.13, but you'll have botocore 1.27.59 which is incompatible.
Successfully installed botocore-1.27.59
Running pip with arguments: ['install', 'boto3==1.33.13']
WARNING: pip is being invoked by an old script wrapper. This will fail in a future version of pip.
Please see https://github.com/pypa/pip/issues/5599 for advice on fixing the underlying issue.
To avoid this problem you can invoke Python with '-m pip' instead of running pip directly.
WARNING: Running pip install with root privileges is generally not a good idea. Try `dqse_ad_job.py install --user` instead.
Requirement already satisfied: boto3==1.33.13 in /usr/local/lib/python3.7/site-packages (1.33.13)
Requirement already satisfied: jmespath<2.0.0,>=0.7.1 in /usr/local/lib/python3.7/site-packages (from boto3==1.33.13) (1.0.0)
Requirement already satisfied: botocore<1.34.0,>=1.33.13 in /usr/local/lib/python3.7/site-packages (from boto3==1.33.13) (1.33.13)
WARNING: No metadata found in /usr/local/lib/python3.7/site-packages
Requirement already satisfied: s3transfer<0.9.0,>=0.8.2 in /usr/local/lib/python3.7/site-packages (from boto3==1.33.13) (0.8.2)
Requirement already satisfied: urllib3<1.27,>=1.25.4; python_version < "3.10" in /usr/local/lib/python3.7/site-packages (from botocore<1.34.0,>=1.33.13->boto3==1.33.13) (1.26.15)
Requirement already satisfied: python-dateutil<3.0.0,>=2.1 in /usr/local/lib/python3.7/site-packages (from botocore<1.34.0,>=1.33.13->boto3==1.33.13) (2.9.0.post0)
Requirement already satisfied: six>=1.5 in /usr/local/lib/python3.7/site-packages (from python-dateutil<3.0.0,>=2.1->botocore<1.34.0,>=1.33.13->boto3==1.33.13) (1.13.0)
Running pip with arguments: ['install', 'botocore==1.33.13']
WARNING: pip is being invoked by an old script wrapper. This will fail in a future version of pip.
Please see https://github.com/pypa/pip/issues/5599 for advice on fixing the underlying issue.
To avoid this problem you can invoke Python with '-m pip' instead of running pip directly.
WARNING: Running pip install with root privileges is generally not a good idea. Try `dqse_ad_job.py install --user` instead.
Requirement already satisfied: botocore==1.33.13 in /usr/local/lib/python3.7/site-packages (1.33.13)
WARNING: No metadata found in /usr/local/lib/python3.7/site-packages
Requirement already satisfied: jmespath<2.0.0,>=0.7.1 in /usr/local/lib/python3.7/site-packages (from botocore==1.33.13) (1.0.0)
Requirement already satisfied: urllib3<1.27,>=1.25.4; python_version < "3.10" in /usr/local/lib/python3.7/site-packages (from botocore==1.33.13) (1.26.15)
Requirement already satisfied: python-dateutil<3.0.0,>=2.1 in /usr/local/lib/python3.7/site-packages (from botocore==1.33.13) (2.9.0.post0)
Requirement already satisfied: six>=1.5 in /usr/local/lib/python3.7/site-packages (from python-dateutil<3.0.0,>=2.1->botocore==1.33.13) (1.13.0)
Traceback (most recent call last):
File "/mnt/tmp/spark-dxxxxxxxx-b436-4f47-xxxx-fb8axxxxxe92/dqse_ad_job.py", line 55, in <module>
import boto3
File "/usr/local/lib/python3.7/site-packages/boto3/__init__.py", line 17, in <module>
from boto3.session import Session
File "/usr/local/lib/python3.7/site-packages/boto3/session.py", line 25, in <module>
from .resources.factory import ResourceFactory
File "/usr/local/lib/python3.7/site-packages/boto3/resources/factory.py", line 17, in <module>
from ..docs import docstring
File "/usr/local/lib/python3.7/site-packages/boto3/docs/__init__.py", line 15, in <module>
from botocore.docs import DEPRECATED_SERVICE_NAMES
ImportError: cannot import name 'DEPRECATED_SERVICE_NAMES' from 'botocore.docs' (/usr/local/lib/python3.7/site-packages/botocore/docs/__init__.py)
So, it seems that everything works fine when botocore 1.33.13 is installed, but not when it decides to install botocore 1.27.59. Furthermore, also in this case I have a situation in which the first time that I run the script, it gives the error, whereas the second time I run it, it works fine.
What else can i try?