Skip to content
Sign upLog in
← Back to Community

Python images

Profile icon
trentgonzales

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

Voters
Profile icon
adhamadham4
Profile icon
LeenAlzoughbi
Profile icon
Brendendawoof
Profile icon
TinaKurpniece
Profile icon
phoebek
Profile icon
PythonDavid
Profile icon
MATTHEWDL
Profile icon
Maithilibp
Profile icon
anvar900
Profile icon
HarveyJosephJos
Comments
hotnewtop
Profile icon
techpixel

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.

Profile icon
trentgonzales

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

Profile icon
a5rocks

@trentgonzales
Well you can use sixels and rob mode

Profile icon
trentgonzales

@a5rocks
rob mode?

Profile icon
a5rocks

@trentgonzales
xxx.yyy.repl.run/rob

Profile icon
trentgonzales

@a5rocks
what does it do?

Profile icon
techpixel

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

Profile icon
MATTHEWDL

2

Profile icon
AlexKerr

alt f4

Profile icon
AaronWrost

thanks homie this helped a lot [email protected]

Profile icon
RyanRana

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!

Profile icon
AllAwesome497

Images? Maybe turtle?

Profile icon
trentgonzales

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

Profile icon
AllAwesome497

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

Profile icon
trentgonzales

@AllAwesome497
ok thx

Profile icon
AllAwesome497

@trentgonzales
Anytime :)

Profile icon
trentgonzales

@AllAwesome497
did I do this right?

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

Profile icon
AllAwesome497

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

Profile icon
AllAwesome497

@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

Profile icon
trentgonzales

@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"?

Profile icon
trentgonzales

@AllAwesome497
ok thx I put PIL

Profile icon
AllAwesome497

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

Profile icon
AllAwesome497

@trentgonzales
np ;)