• 0

Py2EXE Not Importing PIL Properly?


Question

I wrote myself a little QR code generator.  I installed a flatpak of one and it would just straight up crash if you entered too much information, so I decided to just tinker around and write my own in Python that has some proper error handling to warn me if I give it too much to work with instead of just crashing out of the blue.

 

I fired up my Windows 10 VM, did:

python -m pip install qrcode

And a handful of other libraries so that the raw Python file itself runs properly on Windows.  But, when I try to compile it with Py2EXE, the resulting EXE file complains about not being able to import "Image", even though I've double checked that it is indeed installed, so I'm not sure what's going on.  To reiterate, the Python file itself runs fine on that same VM, just not the compiled version of it, so it's something to do with Py2EXE and my setup.py file I guess.

 

This isn't anything mission critical, I don't even have any Windows machines that I use on a daily basis, I'm not being paid for this or anything, I'm just tinkering and with most of my personal projects I do go ahead and compile/package them and stick them on SourceForge.  I've got a handful of little personal things on there that get a couple dozen downloads every week, but that's about it.

 

The source code of the file in question can be found at:

https://gitlab.com/gerowen/qrtxt/-/blob/master/qrtxt.py

 

My setup.py file is as follows:


from distutils.core import setup
import py2exe
setup(
console = [
{
"script": "qrtxt.py",
"icon_resources": [(1, "qrtxt_icon.ico")]
}
],
)

 

Here's a screenshot.  You can see when I try to run the exe file it fails, but when I run the .py file it succeeds and opens the image file.

image.thumb.png.9a110df2c3972785d37097832278d87d.png

Link to comment
Share on other sites

0 answers to this question

Recommended Posts

There have been no answers to this question yet

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now
  • Recently Browsing   0 members

    • No registered users viewing this page.