Skip to content
Advertisement

py-wallpaper returning “is not recognized as an internal or external command”

Hi there,

I am trying to change my windows 11 background wallpaper using the simplest way, so I just found py-wallpaper library where I can:

from wallpaper import set_wallpaper, get_wallpaper

# getting the current wallpaper
print(get_wallpaper())

# setting a new wallpaper
set_wallpaper("FULL_IMG_PATH")

But even if I use one of them I just get this error:

>>> wallpaper.set_wallpaper(r"C:UsersKhaledDownloadsScreenshot 2022-08-13 190317.png")
'C:UsersKhaledAppDataLocalProgramsPythonPython310Libsite-packageswallpaperwin-wallpaper.exe' is not recognized as an internal or external command,
operable program or batch file.
[]

Note: I do not want to use ctypes

Advertisement

Answer

win.py contains the code used to set and load wallpapers. The file contains these lines at the top:

import os

real_path = os.path.realpath(__file__)

win_wallpaper_path = os.path.join(os.path.dirname(real_path), 'win-wallpaper.exe')

The script is trying to call win-wallpaper.exe from wherever win.py is located. Anyway, as the comments mention, the developer didn’t list this requirement, but I looked it up and found this repository on GitHub which seems to be the required program.

The source code of wallpaper.c in that repo is only 41 lines. You can read through the source followed by downloading the binary if you deem it safe.

Advertisement