||I was recently doing some Python scripting and ran into the problem where the first run of the script worked perfectly, but subsequent runs would give the "cannot get exclusive schema lock" error. One of the processes in the script adds the X and Y fields to a table, and it was at this point in the script that the error would occur.
I found a way to fix this problem, and despite the fact that I thought I needed to look for the solution in ArcGIS, in actuality the solution was independent of Arc. In the Windows File Explorer, I looked at the properties of the folder where my script was putting its data. I saw that the folder was set to READ ONLY. After I turned off the read only attribute for the folder, my script worked perfectly - first time and every time thereafter.
So, if you are having this error, clearing the READ ONLY attribute on your folders might solve your problem.