Why is your path to Python C:\Python27\ArcGIS10.5\? I have never seen that before. Also, I NEVER let ArcGIS install Python. Since I do more Python development outside of ESRI than inside, I do the standard Python installation and not the ESRI Python installation. I recommend the following: 1st clean everything up: 1. Uninstall all Python site-packages like NumPy. 2. Uninstall Python. 3. Uninstall all related ESRI software. 4. Check directories to see that the uninstalls are clean. 5. Check your path and remove all paths to Python. 2nd reinstall everything: 1. Install 32 bit Python 2.7.n where n is probabably 13 or 14 now. 2. Install the NumPy and other site packages with pip which is the built-in Python site package installer. 3. Check that you path is properly set for Python. 4. Check that Python will work at the command line and with a test program such as helloworld.py and also try to import NumPy and other site packages 5. Install the ESRI software with Python unchecked so another version of Python is NOT installed. 6. Test Python in ArcGIS. This should work.
... View more
I highly recommend that you do not build your argument strings inside of the ArcPy functions and instead built them outside of the ArcPy functions, assign them to a variable and then pass the variable as an argument to the ArcPy function. What you are doing is a dangerous programming technique and given the problems that the underlying ArcPy argument parsing function gp_fixargs has, it is even more dangerous.
... View more