Home Upgrade Search Memberlist Extras Hacker Tools Award Goals Help Wiki Contact

Python 

IOError: cannot find font file

Hi i use video capture library and PIL for webcam capture.
Everything works fine if I run it as by. But when I compile to exe it and run it i get this error

Code
Traceback (most recent call last):
  File "cam.py", line 25, in <module>
  File "cam.py", line 13, in __init__
  File "VideoCapture.pyc", line 50, in __init__
  File "PIL\ImageFont.pyc", line 247, in load_path
IOError: cannot find font file


I googled then and on the py2exe website i found a solution.
I just should copy the files helvetica-10.pil, helvB08.pil, helvetica-10.png and helvB08.png into the "dist" directory.
And I done it, but I got the same error again.
Please help
Sending a source would be desirable. :)
Oh here it is
Btw i'm using 2.6 version of python

Code
import pygame
from pygame.locals import *
from VideoCapture import Device
import PIL

class webcam:
    def __init__(self):
  self.win = pygame.display.set_mode((500, 500))
  pygame.display.set_caption("Beskrajna igra :D")
  self.screen = pygame.display.get_surface()
  self.cam = Device()
  self.record()

    def record(self):
  fps = 20.0
  img = self.cam.getImage()
  pygame.time.delay(int(1000 * 1.0/fps))
  self.snap = pygame.image.frombuffer(img.tostring(),img.size,img.mode)
  self.screen.blit(self.snap, (0, 0))
  pygame.display.flip()
  self.record()

app = webcam()


Can someone help me please ????
you installed module pil ,VideoCapture ?
(Feb 24, 2011 06:04 PM)chym Wrote:  you installed module pil ,VideoCapture ?

He(/She!?) haves, else it would say ModuleError. Or something like that.
I'm male :D. And yes i have it instaled it works fine until i compile it to exe :S
Are you moving the exe from it's default directory after compiling?
Nope it stays in the dist directory.
i know this is a old thread but i am having the same problem, i was wondering if you found a solution to the problem.
please reply
(Nov 20, 2011 10:02 AM)zodiac876 Wrote:  i know this is a old thread but i am having the same problem, i was wondering if you found a solution to the problem.
please reply

Try http://www.pyinstaller.org/ it has better support for compiling non-standard libs.

And I find it way better then py2exe.
If you've been getting errors like this:

File "PIL\ImageFont.pyc", line ---, in load_path IOError: cannot find font file

The fix is to simply copy the files
Code
helvetica-10.pil, helvB08.pil, helvetica-10.png and helvB08.png
into the "dist" directory.

It may also be needed to add current path in the load_path() function in ImageFont.py (otherwise it searches in sys.path directories only).

Code
for dir in sys.path+['.'] instead of for dir in sys.path


Possibly Related Threads...
Thread / Author Replies Views Last Post
[Python] by The_DroogSep 23, 2016 05:05 AM 2 100 Sep 23, 2016 05:05 AM
Last Post: The_Droog
[.NET] by TrinsechackerJul 15, 2016 01:15 AM 3 200 Jul 15, 2016 01:15 AM
Last Post: Josh‎
[.NET] by [Eprouvez]Jun 9, 2015 01:13 PM 6 373 Jun 9, 2015 01:13 PM
Last Post: SaketSaket