I wrote a fairly simple GUI program to automate a few processes for Windows users in Python (as it is the only programming language I am somewhat familiar with that will run on Windows). I would ideally not want the user to have to run an install program on their machine, as my plan is for it to run self-contained in a USB drive.
It depends on os, shutil, string, sys, tkinter, webbrowser, PIL, ftplib, and glob.
It seems as though all of the dependencies got imported when I ran cx_freeze on it, except for PIL. I have never used cx_freeze before, so I could be doing something wrong but it doesn't seem like it. Running the program from the unfrozen .py script works just fine.
Here's the error message I receive when trying to use a PIL command:
Exception in Tkinter callback
Traceback (most recent call last):
File "C:\Python32\lib\tkinter\__init__.py", line 1399, in __call__
return self.func(*args)
File "E:\AlbumUploader.py", line 143, in OnButton2Click
img.thumbnail(size, Image.ANTIALIAS)
File "C:\Python32\lib\site-packages\PIL\Image.py", line 1573, in thumbnail
self.load()
File "C:\Python32\lib\site-packages\PIL\ImageFile.py", line 168, in load
self.load_prepare()
File "C:\Python32\lib\site-packages\PIL\ImageFile.py", line 234, in load_prepare
self.im = Image.core.new(self.mode, self.size)
File "C:\Python32\lib\site-packages\PIL\Image.py", line 39, in __getattr__
raise ImportError("The _imaging C module is not installed")
ImportError: The _imaging C module is not installed
Thanks for any help you can provide. I see that it's still referencing C:\Python32 which could be part of the problem, because it shouldn't be (if I'm not mistaken).
Update:
I looked at the PIL FAQ and it seems like the gist of that answer is that I need to make sure my sys.path list is correct. I basically grabbed all the Python files for Windows and included it in the USB drive which I am trying to use to contain everything, and set my path like so:
program_dir = os.path.split(sys.argv[0])[0]
sys.path = [program_dir]
sys.path.append(program_dir + os.sep + 'Lib')
sys.path.append(program_dir + os.sep + 'Lib' + os.sep + 'site-packages')
sys.path.append(program_dir + os.sep + 'Lib' + os.sep + 'site-packages' + os.sep + 'PIL')
sys.path.append(program_dir + os.sep + 'DLLs')
All the paths seem correct, but for some reason I am still getting the same error. When I run the .py file everything works 100%, but this seems to break it somehow. Other modules seem to work just fine like shutil, os, and sys, for example.