EEVblog Electronics Community Forum
Products => Computers => Programming => Topic started by: bostonman 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()
-
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.
-
I tried installing PIL, Pillow (thought I read Pillow replaced PIL), etc...
Seems I couldn't install it no matter what format I tried.
-
Run it from the command line and looks at the reported error.
-
>>> pip install pil
File "<stdin>", line 1
pip install pil
-
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.
-
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
-
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.
-
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.)