Pretty much this same question from someone else exists in another forum, but it has no answer. Figured I'd try my luck here. 🙂
I'm working on an Azure function app in Python that just queries a table in ArcGIS Online. It seems to build just fine, but when used it throws the error in the subject line at the point when it attempts to log in to ArcGIS Online.
Curious what might be the cause and solution. Below is the full error:
System.Private.CoreLib: Exception while executing function: Functions.getPercentages. System.Private.CoreLib: Result: Failure
Exception: TypeError: __init__() got an unexpected keyword argument 'method_whitelist'
Stack: File "C:\Program Files\Microsoft\Azure Functions Core Tools\workers\python\3.9/WINDOWS/X64\azure_functions_worker\dispatcher.py", line 407, in _handle__invocation_request
call_result = await self._loop.run_in_executor(
File "C:\Python39\lib\concurrent\futures\thread.py", line 52, in run
result = self.fn(*self.args, **self.kwargs)
File "C:\Program Files\Microsoft\Azure Functions Core Tools\workers\python\3.9/WINDOWS/X64\azure_functions_worker\dispatcher.py", line 649, in _run_sync_func
return ExtensionManager.get_sync_invocation_wrapper(context,
File "C:\Program Files\Microsoft\Azure Functions Core Tools\workers\python\3.9/WINDOWS/X64\azure_functions_worker\extension.py", line 215, in _raw_invocation_wrapper
result = function(**args)
File "*****\getPercentages\__init__.py", line 34, in main
gis = GIS(url, user, pw)
File "*****\.venv\lib\site-packages\arcgis\gis\__init__.py", line 586, in __init__
raise e
File "*****\.venv\lib\site-packages\arcgis\gis\__init__.py", line 525, in __init__
self._portal = _portalpy.Portal(
File "*****\.venv\lib\site-packages\arcgis\gis\_impl\_portalpy.py", line 208, in __init__
self.con = Connection(
File "*****\.venv\lib\site-packages\arcgis\gis\_impl\_con\_connection.py", line 353, in __init__
self._create_session()
File "*****\.venv\lib\site-packages\arcgis\gis\_impl\_con\_connection.py", line 526, in _create_session
max_retries=Retry(
.
Try to install requests 2.29.0 instead of the newest one 2.30
Added: requests==2.29.0
to my requirements file. Still getting the same error.
EDIT - I should say... This works LOCALLY (I run the code from Visual Studio Code and it accepts input and returns data) but when uploaded to Azure it still produces the same error.
After also resetting urllib3 to a lower version, per this answer, it finally worked.
this worked wonderfully. thanks!
I'm getting the same issue here. Currently using arcgis 1.9.1, requests 2.28.1, urllib 1.26.12
Everything has been working fine for months, now getting
__init__() got an unexpected keyword argument 'method_whitelist'
when trying to create a GIS object using the arcgis API
Good Morning Roger
We came across the same problem with a client. As per https://github.com/urllib3/urllib3/issues/2092 it looks like the method_whitelist keyword has been replaced with the allowed_methods keyword in urllib3 this has not been changed in the arcgis api however which causes it to break. We fixed this by going back to a previous version of the arcgis api for python 1.8.4. which solved it for us.
Thanks A LOT! Have been stuck with it, my Google Cloud function suddenly stopped deploying few weeks ago. I tried going back several versions up to to 1.9.1, but finally it worked for 1.8.4 as you suggested. Thank you again! 👏
For publishing Azure Functions that use arcgis api, I am using arcgis==1.9.1 per this thread:
https://community.esri.com/t5/arcgis-api-for-python-questions/suddenly-can-t-build-and-deploy-python...
As mentioned in this original post, this week we started getting the error:
Error: __init__() got an unexpected keyword argument 'method_whitelist'
I looked at the urllib version that got installed when I created a project a while ago using pip install arcgis==1.9.1. The version of urllib3 that got installed at that time was 1.26.12
Today I created a fresh new Azure Function and used pip install arcgis==1.9.1 and the version of urllib3 that got installed today is 2.0.2
So, something changed recently in Esri's specification of what version of urllib3 to use, even for older versions of arcgis api. Apparently the update in terminology to replace "whitelist_methods" with "allowed_methods" has proceeded in urllib3 but has not been updated in arcgis api.
For reference, here is a Github issue:
https://github.com/Esri/arcgis-python-api/issues/1553
and related post in this forum:
In our case, for the time being:
arcgis 1.9.1 + urllib3 1.26.15 (1.26.5 as per Microsoft answer also works)
did the trick