1

I am trying to use pyinstaller 2.0 to build an .exe file from a python script which uses matplotlib and numpy, but I keep failing. I tried this code from Building python pylab/matplotlib exe using pyinstaller as a simple reference, I get the build done for me, but when I run the exe I get the error:

Traceback (most recent call last):
  File "<string>", line 12, in <module>
  File "C:\Compilations\pyinstaller-2.0\PyInstaller\loader\iu.py", line 386, in
importHook
    mod = _self_doimport(nm, ctx, fqname)
  File "C:\Compilations\pyinstaller-2.0\PyInstaller\loader\iu.py", line 480, in
doimport
    exec co in mod.__dict__
  File "C:\Compilations\pyinstaller-2.0\ptest\build\pyi.win32\ptest\out00-PYZ.py
z\PIL.PpmImagePlugin", line 27, in <module>
LookupError: no codec search functions registered: can't find encoding

Is this a bug or do I need to tinker with the .spec file and link the matplotlib libraries to pyinstaller somehow? If so - can anyone show me a simple example, please? I tried cx_Freeze before and also seem to have a problem as soon as I use a code with matplotlib.

Thanks in advance!

Community
  • 1
  • 1
phil_thy
  • 151
  • 1
  • 1
  • 10

1 Answers1

0

Edit PpmImagePlugin.py and add 'import encodings' (without the quotes) before any other imports. I had the same problem and this fixed it. Source: http://www.pyinstaller.org/ticket/651

d0c
  • 515
  • 5
  • 7
  • thanks, but still nothing, same old story... I tried including MPL dir in the spec file (as a pathex list value) but no, still doesn't run - this time it complains: `ImportError: cannot import name namedtuple` – phil_thy Sep 06 '13 at 13:02
  • [namedtuple was introduced in python 2.6](http://docs.python.org/2/library/collections.html#collections.namedtuple). Do you use an earlier version? If yes, try using the [latest version](http://www.python.org/download/releases/2.7.5/) instead and see if the problem persists. – d0c Sep 07 '13 at 12:28
  • A quick google search revealed another [probable](http://stackoverflow.com/a/9733540/2327880) [cause](http://stackoverflow.com/a/9397661/2327880). – d0c Sep 07 '13 at 12:38