ImageDraw.draw.line() : SystemError: new style getargs format but argument is not a tuple
<p>I saw multiple questions on this but was not able to find answer to my problem. Basically I just want to draw a line on an image taking the co-ordinates from a external file in python. And here goes my code :</p>

<pre><code>import Image, ImageDraw
import sys
import csv
im = Image.open("screen.png")
draw = ImageDraw.Draw(im)
with open("outputfile.txt") as file: 
   reader = csv.reader(file, delimiter=' ')
   for row in reader:
      if row[0] == 'H':
        print "Horizontal line" 
        endx = row[2]
        endy = int(row[3])+int(row[1])
      elif row[0] == 'V':
        print "Vertical line"
        endx = row[2]+row[1]
        endy = row[3]
      x = row[2]
      y = row[3]
      draw.line((x,y, endx,endy), fill = 1)
   im.show()
</code></pre>

<p>Everything works except the line :</p>

<pre><code>draw.line((x,y, endx,endy), fill = 1)
</code></pre>

<p>where i see the following error :</p>

<pre><code>File "dummy_test.py", line 21, in &lt;module&gt;
draw.line((x,y, endx,endy), fill = 1)
File "/Library/Python/2.7/site-packages/PIL-1.1.7-py2.7-macosx-10.10-       intel.egg/ImageDraw.py", line 200, in line
self.draw.draw_lines(xy, ink, width)
SystemError: new style getargs format but argument is not a tuple
</code></pre>

<p>If i hard-code the values, I see no problems. Issue happens only on the above case. Can anyone point out the problem?</p>

<p>Looks like just few <code>int(...)</code> were missing?</p>

<pre><code>--- a.py.ORIG   2016-09-14 20:54:47.442291244 +0200
+++ a.py    2016-09-14 20:53:34.990627259 +0200
@@ -1,4 +1,4 @@
-import Image, ImageDraw
+from PIL import Image, ImageDraw
 import sys
 import csv
 im = Image.open("screen.png")
@@ -8,13 +8,13 @@
    for row in reader:
       if row[0] == 'H':
         print "Horizontal line" 
-        endx = row[2]
+        endx = int(row[2])
         endy = int(row[3])+int(row[1])
       elif row[0] == 'V':
         print "Vertical line"
-        endx = row[2]+row[1]
-        endy = row[3]
-      x = row[2]
-      y = row[3]
+        endx = int(row[2])+int(row[1])
+        endy = int(row[3])
+      x = int(row[2])
+      y = int(row[3])
       draw.line((x,y, endx,endy), fill = 1)
    im.show()
</code></pre>

python