Viewing JPG Images in Python Using XP - Page 1
Forum section: electronics / general

author: bostonman
author_rank: Super Contributor
timestamp: September 18, 2023, 02:07:27 am
content: 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 imageim = Image.open("image.jpg")#show imageim.show()

author: ataradov
author_rank: Super Contributor
timestamp: September 18, 2023, 02:16:09 am
content: 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.

author: bostonman
author_rank: Super Contributor
timestamp: September 18, 2023, 02:53:56 am
content: I tried installing PIL, Pillow (thought I read Pillow replaced PIL), etc...Seems I couldn't install it no matter what format I tried.

author: ataradov
author_rank: Super Contributor
timestamp: September 18, 2023, 02:57:07 am
content: Run it from the command line and looks at the reported error.

author: bostonman
author_rank: Super Contributor
timestamp: September 18, 2023, 03:02:55 am
content: >>> pip install pilFile "<stdin>", line 1pip install pil

author: ataradov
author_rank: Super Contributor
timestamp: September 18, 2023, 03:15:57 am
content: 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.

author: bostonman
author_rank: Super Contributor
timestamp: September 18, 2023, 03:36:56 am
content: 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

author: ataradov
author_rank: Super Contributor
timestamp: September 18, 2023, 03:48:50 am
content: 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.

author: abeyer
author_rank: Frequent Contributor
timestamp: September 18, 2023, 08:05:02 pm
content: 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 notcertainabout this... but if you absolutely must stick with XP, youmighthave 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.)