Author Topic: Viewing JPG Images in Python Using XP  (Read 806 times)

0 Members and 1 Guest are viewing this topic.

Offline bostonmanTopic starter

  • Super Contributor
  • ***
  • Posts: 1904
  • Country: us
Viewing JPG Images in Python Using XP
« on: September 18, 2023, 02:07:27 am »
I have an XP machine with Python 3.3 and I'm trying to create a program that will view images in a directory randomly. I'm starting with the basic approach of trying to just open/view an image and found multiple ways to do it, however, none of them work (after I figure out this, then I'll move onto incorporating a random viewing program).

I'm using Notepad++, saving it as a filename.py, and double clicking the .py file.

The most basic one that I found that causes a window to open and close without doing anything else is:

from PIL import Image

#read the image
im = Image.open("image.jpg")

#show image
im.show()
 

Online ataradov

  • Super Contributor
  • ***
  • Posts: 11428
  • Country: us
    • Personal site
Re: Viewing JPG Images in Python Using XP
« Reply #1 on: September 18, 2023, 02:16:09 am »
You nee to run it from the command line or some IDE and you will see the error output. In this specific case you likely have no PIL library installed.
Alex
 

Offline bostonmanTopic starter

  • Super Contributor
  • ***
  • Posts: 1904
  • Country: us
Re: Viewing JPG Images in Python Using XP
« Reply #2 on: September 18, 2023, 02:53:56 am »
I tried installing PIL, Pillow (thought I read Pillow replaced PIL), etc...

Seems I couldn't install it no matter what format I tried.
 

Online ataradov

  • Super Contributor
  • ***
  • Posts: 11428
  • Country: us
    • Personal site
Re: Viewing JPG Images in Python Using XP
« Reply #3 on: September 18, 2023, 02:57:07 am »
Run it from the command line and looks at the reported error.
Alex
 

Offline bostonmanTopic starter

  • Super Contributor
  • ***
  • Posts: 1904
  • Country: us
Re: Viewing JPG Images in Python Using XP
« Reply #4 on: September 18, 2023, 03:02:55 am »
>>> pip install pil
  File "<stdin>", line 1
    pip install pil
 

Online ataradov

  • Super Contributor
  • ***
  • Posts: 11428
  • Country: us
    • Personal site
Re: Viewing JPG Images in Python Using XP
« Reply #5 on: September 18, 2023, 03:15:57 am »
What is this? pip is not a Python command, it is a separate utility. You run it from the command line, not from the python itself.

Also, run your program and see what  is the actual error.
Alex
 

Offline bostonmanTopic starter

  • Super Contributor
  • ***
  • Posts: 1904
  • Country: us
Re: Viewing JPG Images in Python Using XP
« Reply #6 on: September 18, 2023, 03:36:56 am »
that's what I found on one of the websites that explained how to install PIL.

Let me tinker a bit more. I'm finding Python to be confusing
 

Online ataradov

  • Super Contributor
  • ***
  • Posts: 11428
  • Country: us
    • Personal site
Re: Viewing JPG Images in Python Using XP
« Reply #7 on: September 18, 2023, 03:48:50 am »
You misunderstood the site. pip should be called from the OS command line, the same way you've got that Python prompt. Instead of typing "python", type that pip command.

Alex
 

Offline abeyer

  • Frequent Contributor
  • **
  • Posts: 318
  • Country: us
Re: Viewing JPG Images in Python Using XP
« Reply #8 on: September 18, 2023, 08:05:02 pm »
You're likely to have ongoing struggles with python 3 on Windows XP, as no currently supported versions of python 3 still support XP. Thus there likely won't be binary wheels for the older 3.x releases that support XP for any current versions of packages that include c extension code, and windows doesn't easily compile c code, so you'll have to get a compiler set up and working and be building your own cpython and/or extension modules (which seems untenable given it sounds like you have limited experience with python.)

I'm not certain about this... but if you absolutely must stick with XP, you might have better luck using a python 2 build for XP. Normally I wouldn't ever encourage someone to do that for anything new, but it may be the path of least resistance to support such old systems. (though be aware there are significant breaking changes between python 2 and 3, so you can't expect the same code to work on both.)
 


Share me

Digg  Facebook  SlashDot  Delicious  Technorati  Twitter  Google  Yahoo
Smf