Image Processing Problem

I use the cImage files from since the original does not suffice my need. However, the code can’t work. What’s the problem?

Did you follow the instructions on how and what to install?

I downloaded it directly and put all the files in the folder into the relit Files.

I think there might be some issue with the tkinter in replit library in my humble opinion.

there have been problems in the past. To know it, can you share the error you get (even better the repl)?

I am a beginner in programming; I think it is relevant to the issue mentioned in stackoverflow. There will be another link in the bottom of the page with regard to a similar problem in the link that I post here.

Can you share the error you get? Sharing links you find around does not help helping you.

Python turtle on Replit
Traceback (most recent call last):
  File "/home/runner/HW7111652004/", line 26, in <module>
  File "<frozen importlib._bootstrap_external>", line 883, in exec_module
  File "<frozen importlib._bootstrap>", line 241, in _call_with_frames_removed
  File "/home/runner/HW7111652004/", line 65, in <module>
  File "/home/runner/HW7111652004/", line 52, in makeNeg
  File "/home/runner/HW7111652004/", line 493, in draw = self.canvas.create_image(self.centerX,self.centerY,image=ig)
  File "/nix/store/9kzgdmf4q5vxshisils7pzgc6342pcsy-python3-3.10.0/lib/python3.10/tkinter/", line 2819, in create_image
    return self._create('image', args, kw)
  File "/nix/store/9kzgdmf4q5vxshisils7pzgc6342pcsy-python3-3.10.0/lib/python3.10/tkinter/", line 2805, in _create
_tkinter.TclError: image "pyimage2" doesn't exist
repl process died unexpectedly: exit status 1
Python turtle on Replit

Do you have two statements in your code of the type Tk()?

No. Here is my code.

import image

def negPix(oldPix):
    return image.Pixel(255-oldPix.getRed(), 255-oldPix.getGreen(), 255-oldPix.getBlue())

def makeNeg(imageFile):
    oldImg = image.FileImage(imageFile)
    width = oldImg.getWidth()
    height = oldImg.getHeight()
    wn = image.ImageWin(width*2, height, "IMGPros")
    newImg = image.EmptyImage(width, height)

    for row in range(height):
        for col in range(width):
            oldPix = oldImg.getPixel(col, row)
            newPix = negPix(oldPix)
            newImg.setPixel(col, row, newPix)

    newImg.setPosition(width + 1, 0)


I even didn’t import tk.

On the error message was the calling tk, so the problem may be on or on tk in replit’s library. But this code works on my classmates’ notebook (Windows, using VS code or IDLE). I am using MacBook by the way. I don’t know if it affects or not.

Replit does not care on what you use.
If possible, could you share your repl so I can try to fork it and run it also?

I use teams. I fork it to be public and the forked one is here. It can’t be adjust to be public or private on the original replit.

Yes I have the same issue. It works locally but not on REPL. cannot understand why either

On your repl, is being used as the interpreter because it’s a ‘Python (with Turtle)’ repl (why?), which is where the second Tk instance is coming from.
Files ⋮ > Show hidden files. In the .replit file

  1. Remove the interpreter section
  2. Add a line at the start
run = "python"

Sneaky. I did not even know there is something like that in repl, OT please check and mark @UMARismyname post as solution

Thank you for solving my problem!

1 Like

This topic was automatically closed 7 days after the last reply. New replies are no longer allowed.