I'm running a simple python script from arcmap that sends an html post and processes the response. This script runs just fine from pythonwin but for some reason I receive the following error when running the script from an arcmap toolbox: AttributeError: 'NoneType' object has no attribute 'split'

The python code and stack trace is below. I'm stumped why it would run outside of arcmap but not within. I'm sure it's something simple I'm missing. Hopefully someone can point it out. :)

for row in cursor:
        arcpy.SetProgressorLabel("Loading {0}...".format(row))
        url = "https://myurl.com"

        payload = "streetAddress="+row[0]+"&city="+row[1]+"&state="+row[2]+"&zip="+row[3]+"&apikey="+apikey+"&format=csv&census=false&censusYear=2000|2010&notStore=false&version=4.01"

        headers = {
            'accept': "application/x-www-form-urlencoded",
            'content-type': "application/x-www-form-urlencoded",
            'access-control-allow-origin': "*"

        response = requests.request("POST", url, data=payload, headers=headers)
        responseList = response.text.split(',')


Traceback (most recent call last):
  File "C:\Development\PythonAddins\TAMUGeocoder.py", line 75, in <module>
    response = requests.request("POST", url, data=payload, headers=headers)
  File "C:\Python27\ArcGIS10.1\lib\site-packages\requests\api.py", line 53, in request
    return session.request(method=method, url=url, **kwargs)
  File "C:\Python27\ArcGIS10.1\lib\site-packages\requests\sessions.py", line 456, in request
    prep = self.prepare_request(req)
  File "C:\Python27\ArcGIS10.1\lib\site-packages\requests\sessions.py", line 389, in prepare_request
    hooks=merge_hooks(request.hooks, self.hooks),
  File "C:\Python27\ArcGIS10.1\lib\site-packages\requests\models.py", line 293, in prepare
    self.prepare_url(url, params)
  File "C:\Python27\ArcGIS10.1\lib\site-packages\requests\models.py", line 362, in prepare_url
    host = host.encode('idna').decode('utf-8')
  File "C:\Python27\ArcGIS10.1\Lib\encodings\idna.py", line 157, in encode
    labels = dots.split(input)
AttributeError: 'NoneType' object has no attribute 'split'
  • This doesn't appear to be an arcpy issue -- the entire stack is within the requests library.
    – Vince
    Mar 15, 2016 at 21:03
  • I agree completely, but the fact remains that it works run alone but not when run within arcmap. Any ideas why?
    – pbaldridge
    Mar 15, 2016 at 21:06
  • 1
    Is it the same build of Python? 32-/64-bit?
    – Vince
    Mar 15, 2016 at 21:12
  • That was my first thought, but sys.version is showing the same for both: version: 2.7.2 (default, Jun 12 2011, 15:08:59) [MSC v.1500 32 bit (Intel)]
    – pbaldridge
    Mar 15, 2016 at 21:35
  • 1
    My 10.3 doesn't have requests in it. Did you install the same site library in both the ArcGIS and Python install? Unfortunately, this sort of customization is probably outside the realm of Tech Support.
    – Vince
    Mar 15, 2016 at 23:02

2 Answers 2


The error

AttributeError: 'NoneType' object has no attribute 'split' 

often indicates that the attribute you are trying to split is Null, meaning there is no value in it to split.

You need to check the attribute is not Null before splitting. Something like

if not response.text == None: 
    responseList = response.text.split(',')
  • The problem is that the split is occurring within request library, not any code of mine and works fine in pythonwin, just not in arcmap which makes debugging more difficult. I have placed messages to try and track it down and have found the following. models.py calls host = host.encode('idna').decode('utf-8') and I placed a msg at that point displaying the url being passed which is correct. I then placed a msg in idna.py at the beginning of the encode() function to print the url being received there but that msg is never hit. Stepping through a debugger everything looks fine, just not arcmap
    – pbaldridge
    Mar 16, 2016 at 12:58

I'm still not sure what the issue was, but updating python to 2.7.11 fixed whatever it was. I checked that both python and ArcGIS were using the same version but perhaps there was something awry in the paths.. corrupted library.. just not sure. Thanks for all the input to those who answered.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.