ModuleNotFoundError: No module named ‘trimage’ on Arch Linux

It’s been a minute since I’ve last used Trimage. I probably installed it when I had initially setup Arch Linux on this system. Curious about whether or not an image that was part of a pull request I was reviewing could be improved, I launched the app.

Much to my dismay, nothing happened. No flash of the app before crashing. Not a peep of an error message. Nothing. So I tried to launch the app from the command-line:

% trimage
Traceback (most recent call last):
  File "/usr/bin/trimage", line 19, in <module>
    import trimage
ModuleNotFoundError: No module named 'trimage'
Zsh

At it’s core, Trimage is a Python application. Why it was complaining that it couldn’t find the module is a mystery.

Finding the trimage module

So I did some research. Arch Linux has great resources, so I checked the package’s page in the Arch User Repository. Seemed like I wasn’t alone, but there definitely was a lack of movement on the topic.

Some suggestions were related to removing some other dependency, and that should resolve it. It all seemed a bit more involved than I would have liked.

Often in the AUR there will be multiple copies of a package, a stable version, and a “git” version. The git version, usually suffixed with -git will pull the latest and greatest code, and not a specific version.

Arch has a trimage-git package, but I opt for the stable version when available. Since the stable version was giving me grief, I installed trimage-git, which also removed the trimage package:

:: trimage-git-1.0.6.r16.gad74684-1 and trimage-1.0.6-2 are in conflict. Remove trimage? [y/N] y

Packages (2) trimage-1.0.6-2 [removal]  trimage-git-1.0.6.r16.gad74684-1

Total Installed Size:   0.16 MiB
Net Upgrade Size:      -0.01 MiB

:: Proceed with installation? [Y/n] 
(1/1) checking keys in keyring                                                                                     [#####################################################################] 100%
(1/1) checking package integrity                                                                                   [#####################################################################] 100%
(1/1) loading package files                                                                                        [#####################################################################] 100%
(1/1) checking for file conflicts                                                                                  [#####################################################################] 100%
(2/2) checking available disk space                                                                                [#####################################################################] 100%
:: Processing package changes...
(1/1) removing trimage                                                                                             [#####################################################################] 100%
(1/1) installing trimage-git                                                                                       [#####################################################################] 100%
:: Running post-transaction hooks...
(1/3) Arming ConditionNeedsUpdate...
(2/3) Updating icon theme caches...
(3/3) Updating the desktop file MIME type cache...
Zsh

After it installed, I tried to run trimage again, and it worked!

Curious if that was actually the fix, I went ahead and installed trimage (replacing trimage-git) and tried to run it again.

It still worked!

My conclusion at this point is that something got screwy with the package during some update I had run previously. Reinstalling the package seemed to flush out the gremlins and get my moving again.

Josh Sherman - The Man, The Myth, The Avatar

About Josh

Husband. Father. Pug dad. Musician. Founder of Holiday API, Head of Engineering and Emoji Specialist at Mailshake, and author of the best damn Lorem Ipsum Library for PHP.


If you found this article helpful, please consider buying me a coffee.