Ask coding questions

← Back to all posts
Python images
trentgonzales (7)

How do I get an image to show in my python program?

Commentshotnewtop
HarperframeInc (240)

Hi Trentgonzales.
Because Python is a console, It would not be able to show images.
The only way to show images is via. tkinter, which is unavailable to repl.it as of right now.

Please upvote this post if it helped you.

trentgonzales (7)

@HarperframeInc ok then, is there a program that does support pictures?

a5rocks (535)

@trentgonzales Well you can use sixels and rob mode

HarperframeInc (240)

@trentgonzales No, but using an online website, it is possible to turn an image into ascii text.

RyanRana (184)

Well depending on how new you are there are a few ways you can do it. Python console(IDLE) does not support pictures, although if you want you can use Turtle API, and this link provides you with some nice tutorials on the Turtle (https://media.readthedocs.org/pdf/pythonturtle/latest/pythonturtle.pdf)
That is pretty basic, but for some more advanced stuff you can learn GUI(Graphical User Interface), from this link for a series on the topic(https://www.youtube.com/watch?v=NZLM0VQEKGY&list=PLgUv3ixQPhJv4gqUwVk_XLo-7NWTc9c6c)

Like this post if it helped!

trentgonzales (7)

@AllAwesome497 What is turtle? Sorry, I am kinda new to this.

AllAwesome497 (248)

@trentgonzales like a mix of a few things.... hard to explain.
https://www.geeksforgeeks.org/working-images-python/amp/
try that, and keep programming! ;)

trentgonzales (7)

@AllAwesome497 did I do this right?

img = Image.open("book.jpg")

AllAwesome497 (248)

@trentgonzales idk- never touched images, never felt the need. Is there a problem with it?

AllAwesome497 (248)

@trentgonzales If that doesn't work, make a new file in the repl called requirements.txt (EXACTLY that) (if u haven't already) then in its own line put in the word Pillow that is the equivalent to pip install. then at the beggining of the python file put in from PIL import Image

trentgonzales (7)

@AllAwesome497 it's not showing, I'm trying to get images to show. It doesn't say anything about showing them, but it does say something about a "Relative path"?

AllAwesome497 (248)

@trentgonzales Is the file uploaded in the repl, and in the same folder (if any) as the py folder?