Background: I’m working with python 3.2 in Eclipse SDK 4.2.1 (Juno), and I noticed something strange – while my programs run perfectly in Eclipse, they always close with an error if I open them from the file manager. I managed to get a screenshot before the cmd closed: 
It seems that the program is inserting an additional “\” between “images” and “Cy.png”. However, I can’t just remove a slash from my program – in it, I used two slashes because you need to to include a slash in a string.
My program is as follows:
from PIL import Image
def pathConstruction(count, imageName):
l = []
l.append('images\\')
if count == 1:
l.append('Sepia')
l.append(imageName)
imagePath = ''.join(l)
return imagePath
def grayscale(pix, width, height):
for col in range(width):
for row in range(height):
r,g,b = pix[col, row]
avg = ((r + g + b) / 3)
r = int(avg)
g = int(avg)
b = int(avg)
pix[col, row] = r,g,b
def sepia(pix, width, height):
for col in range(width):
for row in range(height):
r,g,b = pix[col, row]
newR = (r * 0.393 + g * 0.769 + b * 0.189)
newG = (r * 0.349 + g * 0.686 + b * 0.168)
newB = (r * 0.272 + g * 0.534 + b * 0.131)
pix[col, row] = int(newR),int(newG),int(newB)
imageName = input("Please input the full name of your image, including extension: ")
count = 0
imagePath= pathConstruction(count, imageName)
count = count + 1
img = Image.open(imagePath)
pix = img.load()
width, height = img.size
grayscale(pix, width, height)
sepia(pix, width, height)
imagePath = pathConstruction(count, imageName)
img.save(imagePath)
img.show()
Question: What can I do to run this program outside of Eclipse?
I think the problem is not the extra backslash you’re seeing between the directory and the file name (which I think it just from the
reprof the string), but instead the\rthat’s added at the end. I’m not sure why you’d get that included in the value frominput, but you can remove it by callingstripon the string.