close Comments you submit will be routed for moderation. If you have an account, please log in first.
Modify

#651 closed defect (fixed)

no codec search functions registered

Reported by: blacksheep.cx@… Owned by: matysek
Priority: normal Milestone: PyInstaller 2.1
Component: PyInstaller Version: develop
Severity: normal Keywords: encodings, codec, codecs
Cc:

Description

Hi,

Hope someone can help me with following issue.

"LookupError?: no codec search functions registered: can't find encoding"

LinuxMint? Version 13 (maya) (64-Bit) + Python 2.7.3

Additional infos (Traceback, spec-file, build-log) attached as .txt

thanks
chris

Attachments (1)

LookupError.txt (6.5 KB) - added by blacksheep.cx@… 16 months ago.
Traceback, spec-file, build-log

Download all attachments as: .zip

Change History (26)

Changed 16 months ago by blacksheep.cx@…

Traceback, spec-file, build-log

comment:1 Changed 14 months ago by martinfitzp

I have the same issue as the OP, when building an .app on MacOSX (also PySide? based). I've found a fix by adding the runtime hook for the encodings:

runtime_hooks=PyInstaller/loader/rthooks/pyi_rth_encodings.py?,

Adding that allowed the app to run fine (albeit with a subsequent PySide?.QtNetwork?/QWebkit error).

Hopefully that'll help point in the right direction. Thanks,

comment:2 Changed 14 months ago by martin.fitzpatrick@…

I have the same problem in a Mac .app bundle using PySide? (I see the OP was also using PySide?). It builds fine but running the app produces:

File "<appname>/build/pyi.darwin/<appname>/out00-PYZ.pyz/plistlib", line 436, in getData
LookupError?: no codec search functions registered: can't find encoding

comment:3 Changed 14 months ago by anonymous

I also have this problem (plistlib not finding encoding). Adding the encodings runtime hook does not resolve it for me though. Are there any updates on this issue?

comment:4 Changed 13 months ago by anonymous

Same error on Windows 7 Python 2.7.3, PIL 1.1.7

File "PyInstaller? folder\build\pyi.win32\Photo Gallery Manager\out00-PYZ.pyz\P
IL.PpmImagePlugin?", line 27, in <module>
LookupError?: no codec search functions registered: can't find encoding

...
PYTHONHOME=S:/Users/alex/AppData/Local/Temp/_MEI95082/
importing modules from CArchive
extracted iu
extracted struct
extracted archive
Installing import hooks
out00-PYZ.pyz
Running scripts
Traceback (most recent call last):

File "<string>", line 12, in <module>
File "D:\Programming\Python\Libraries\pyinstaller-2.0\PyInstaller?\loader\iu.py

", line 386, in importHook

mod = _self_doimport(nm, ctx, fqname)

File "D:\Programming\Python\Libraries\pyinstaller-2.0\PyInstaller?\loader\iu.py

", line 480, in doimport

exec co in mod.dict

File "PyInstaller? folder\build\pyi.win32\Photo Gallery Manager\out00-PYZ.pyz\P

IL.PpmImagePlugin?", line 27, in <module>
LookupError?: no codec search functions registered: can't find encoding
RC: -1 from pyi_rth_PIL_Image
...

comment:5 Changed 13 months ago by matysek

Does this happen with the development version?

comment:6 Changed 13 months ago by jsilver@…

I see the same behavior with the development version. I have OSX 10.8.3 and python 2.7.3. Here is the output from the following pyinstaller build ../tools/pyinstaller-dev/pyinstaller.py -F --log-level=DEBUG mm.py - http://pastebin.com/fQKCavEG - which results in this error when I try to execute the frozen binary:

Traceback (most recent call last):
  File "<string>", line 11, in <module>
  File "/Users/username/workspace/project/tools/pyinstaller-dev/PyInstaller/loader/pyi_importers.py", line 268, in load_module
    exec(bytecode, module.__dict__)
  File "/Users/username/workspace/project/mm/build/pyi.darwin/mm/out00-PYZ.pyz/pkg_resources", line 730, in <module>
  File "/Users/username/workspace/project/mm/build/pyi.darwin/mm/out00-PYZ.pyz/pkg_resources", line 733, in Environment
  File "/Users/username/workspace/project/mm/build/pyi.darwin/mm/out00-PYZ.pyz/pkg_resources", line 115, in get_supported_platform
  File "/Users/username/workspace/project/mm/build/pyi.darwin/mm/out00-PYZ.pyz/pkg_resources", line 227, in _macosx_vers
  File "/Users/username/workspace/project/mm/build/pyi.darwin/mm/out00-PYZ.pyz/platform", line 804, in mac_ver
  File "/Users/username/workspace/project/mm/build/pyi.darwin/mm/out00-PYZ.pyz/platform", line 781, in _mac_ver_xml
  File "/Users/username/workspace/project/mm/build/pyi.darwin/mm/out00-PYZ.pyz/plistlib", line 78, in readPlist
  File "/Users/username/workspace/project/mm/build/pyi.darwin/mm/out00-PYZ.pyz/plistlib", line 406, in parse
  File "/Users/username/workspace/project/mm/build/pyi.darwin/mm/out00-PYZ.pyz/plistlib", line 418, in handleEndElement
  File "/Users/username/workspace/project/mm/build/pyi.darwin/mm/out00-PYZ.pyz/plistlib", line 452, in end_key
  File "/Users/username/workspace/project/mm/build/pyi.darwin/mm/out00-PYZ.pyz/plistlib", line 436, in getData
LookupError: no codec search functions registered: can't find encoding

And

comment:7 Changed 13 months ago by doublesharp

FWIW - the current release won't compile at all, it results in the following:

4855 DEBUG: Analyzing /usr/local/Cellar/python/2.7.3/Frameworks/Python.framework/Versions/2.7/Resources/Python.app/Contents/MacOS/Python
Traceback (most recent call last):
  File "../tools/pyinstaller/pyinstaller.py", line 91, in <module>
    main()
  File "../tools/pyinstaller/pyinstaller.py", line 86, in main
    run_build(opts, spec_file)
  File "../tools/pyinstaller/pyinstaller.py", line 50, in run_build
    PyInstaller.build.main(spec_file, **opts.__dict__)
  File "/Users/username/workspace/project/tools/pyinstaller/PyInstaller/build.py", line 1625, in main
    build(specfile, buildpath)
  File "/Users/username/workspace/project/tools/pyinstaller/PyInstaller/build.py", line 1582, in build
    execfile(spec)
  File "/Users/username/workspace/project/mm/mm.spec", line 5, in <module>
    hookspath=None)
  File "/Users/username/workspace/project/tools/pyinstaller/PyInstaller/build.py", line 389, in __init__
    self.__postinit__()
  File "/Users/username/workspace/project/tools/pyinstaller/PyInstaller/build.py", line 315, in __postinit__
    self.assemble()
  File "/Users/username/workspace/project/tools/pyinstaller/PyInstaller/build.py", line 451, in assemble
    manifest=depmanifest)[1:])
  File "/Users/username/workspace/project/tools/pyinstaller/PyInstaller/bindepend.py", line 158, in Dependencies
    for lib, npth in selectImports(pth, xtrapath):
  File "/Users/username/workspace/project/tools/pyinstaller/PyInstaller/bindepend.py", line 381, in selectImports
    dlls = getImports(pth)
  File "/Users/username/workspace/project/tools/pyinstaller/PyInstaller/bindepend.py", line 573, in getImports
    return _getImports_macholib(pth)
  File "/Users/username/workspace/project/tools/pyinstaller/PyInstaller/bindepend.py", line 474, in _getImports_macholib
    m = MachO(pth)
  File "/Users/username/workspace/project/tools/pyinstaller/PyInstaller/lib/macholib/MachO.py", line 69, in __init__
    self.load(fp)
  File "/Users/username/workspace/project/tools/pyinstaller/PyInstaller/lib/macholib/MachO.py", line 84, in load
    self.load_header(fh, 0, size)
  File "/Users/username/workspace/project/tools/pyinstaller/PyInstaller/lib/macholib/MachO.py", line 114, in load_header
    hdr = MachOHeader(self, fh, offset, size, magic, hdr, endian)
  File "/Users/username/workspace/project/tools/pyinstaller/PyInstaller/lib/macholib/MachO.py", line 154, in __init__
    self.load(fh)
  File "/Users/username/workspace/project/tools/pyinstaller/PyInstaller/lib/macholib/MachO.py", line 233, in load
    cmd_data = fh.read(data_size)
  File "/Users/username/workspace/project/tools/pyinstaller/PyInstaller/lib/macholib/util.py", line 92, in read
    assert size >= 0
AssertionError

comment:8 Changed 13 months ago by matysek

  • Component changed from Platform *nix to PyInstaller
  • Owner changed from htgoebel to matysek

Could you please provide simple code example that reproduces this error?

comment:9 Changed 13 months ago by doublesharp

Sorry, I don't. I'm somewhat new to python and am just trying to use pyinstaller to test some modifications to a tool I am using to work with Apex code on Salesforce.com through Sublime Text.

I'm getting the error when trying to build /mm/mm.py from the Mavens Mate project, the source is here and comes with pyinstaller and pyinstaller-dev under /tools however I tried downloading from the pyinstaller.org site as well with the same results.

comment:10 Changed 13 months ago by doublesharp

Although as far as I know I didn't do anything different, the file would temporarily compile for me but would throw an error when I tried to run it it would throw an error about an invalid URL when trying to access the Salesforce partner WSDL, indicating that perhaps it is a path issue? -

> echo '{"project_name": "mrm"}' | ~/workspace/MavensMate/mm/dist/mm -c SUBLIME_TEXT_3 -o index_apex_overlays
{"body": "unknown url type: /var/folders/84/81q1wl5d5k58flxbpcgqq78w0000gn/T/_MEIHxOnNJ/lib/wsdl/partner.xml", "body_type": "text", "success": false}

This command works fine when I run it against the mm.py file directly.

Recompiling it a couple more times (with and without the --runtime-hook=../tools/pyinstaller-dev/PyInstaller/loader/rthooks/pyi_rth_encodings.py option) once again results in the encoding error.

comment:11 follow-up: Changed 12 months ago by michkapopoff@…

Same problem here with 10.8.3 and python 2.7 from macports.

Here is the traceback :

Traceback (most recent call last):
  File "<string>", line 11, in <module>
  File "/Users/michkapopoff/Desktop/pyinstaller-branch/main/dist/main/eggs/setuptools-0.6c11-py2.7.egg/pkg_resources.py", line 698, in <module>
  File "/Users/michkapopoff/Desktop/pyinstaller-branch/main/dist/main/eggs/setuptools-0.6c11-py2.7.egg/pkg_resources.py", line 701, in Environment
  File "/Users/michkapopoff/Desktop/pyinstaller-branch/main/dist/main/eggs/setuptools-0.6c11-py2.7.egg/pkg_resources.py", line 99, in get_supported_platform
  File "/Users/michkapopoff/Desktop/pyinstaller-branch/main/dist/main/eggs/setuptools-0.6c11-py2.7.egg/pkg_resources.py", line 209, in _macosx_vers
  File "/Users/michkapopoff/Desktop/pyinstaller-branch/main/build/main/out00-PYZ.pyz/platform", line 804, in mac_ver
  File "/Users/michkapopoff/Desktop/pyinstaller-branch/main/build/main/out00-PYZ.pyz/platform", line 781, in _mac_ver_xml
  File "/Users/michkapopoff/Desktop/pyinstaller-branch/main/build/main/out00-PYZ.pyz/plistlib", line 78, in readPlist
  File "/Users/michkapopoff/Desktop/pyinstaller-branch/main/build/main/out00-PYZ.pyz/plistlib", line 406, in parse
  File "/Users/michkapopoff/Desktop/pyinstaller-branch/main/build/main/out00-PYZ.pyz/plistlib", line 418, in handleEndElement
  File "/Users/michkapopoff/Desktop/pyinstaller-branch/main/build/main/out00-PYZ.pyz/plistlib", line 452, in end_key
  File "/Users/michkapopoff/Desktop/pyinstaller-branch/main/build/main/out00-PYZ.pyz/plistlib", line 436, in getData
LookupError: no codec search functions registered: can't find encoding

Here is some code to reproduce the error (does the same using : from pylab import * instead of import matplotlib.pyplot as plt) :

#!/usr/bin/env python

import matplotlib.pyplot as plt

def main():
    x = range(0, 10)
    plt.plot(x)
    plt.draw()
    plt.show()
    
if __name__ == "__main__":
    main()

comment:12 in reply to: ↑ 11 Changed 12 months ago by matysek

Replying to michkapopoff@…:

Same problem here with 10.8.3 and python 2.7 from macports.

#!/usr/bin/env python

import matplotlib.pyplot as plt

def main():
    x = range(0, 10)
    plt.plot(x)
    plt.draw()
    plt.show()
    
if __name__ == "__main__":
    main()

I'm not able to reproduce this issue with this code example.

  • python 2.7 from macports, osx 10.7.5
  • Do you use virtualenv?

Where could be the difference, virtualenv?

comment:13 Changed 12 months ago by doublesharp

Everything started working for me after I installed python using Homebrew and specifying to use shared libraries. Assuming you have brew and are ok with installing python to /usr/local/bin this is what worked for me:

brew install python --configure="--enable-shared"

I would assume there is a similar argument for Macports, but I'm not sure. In my case I updated my path to use the brewed version of python and not the system's, but using the full path when calling PyInstaller? seems to work as well.

For the project I was working on, I had to remove and reinstall libraries with pip that existed before I compiled with the shared libraries option - it would work fine locally but would fail when I tried to run the executables. The full setup guide I wrote, in case it's helpful, is located here: https://github.com/joeferraro/MavensMate/wiki/Developer-Guide

comment:14 Changed 12 months ago by michkapopoff@…

I just tested on 10.7.5 on another mac, python 2.7 from macports, and I do have the error.

I do not use virtualenv.

If the --enable-shared option is the problem, my python installation was done with :

sudo port install python27

I don't know if there is an --enable-shared option in macports, and if this would make a difference ?

comment:15 Changed 12 months ago by michkapopoff@…

I did some more tests this morning. I installed homebrew on OS X 10.7.5, installed python (and checked if I was using the right one), and I tested pyinstaller with and without --configure="--enable-shared". I also updated my Xcode which was one version behind.

I get the same error for the two possibilities :

Traceback (most recent call last):
  File "<string>", line 11, in <module>
  File "/Users/michkapopoff/Desktop/pyinstaller-develop/PyInstaller/loader/pyi_importers.py", line 270, in load_module
    exec(bytecode, module.__dict__)
  File "/Users/michkapopoff/Desktop/pyinstaller-develop/main/build/main/out00-PYZ.pyz/pkg_resources", line 730, in <module>
  File "/Users/michkapopoff/Desktop/pyinstaller-develop/main/build/main/out00-PYZ.pyz/pkg_resources", line 733, in Environment
  File "/Users/michkapopoff/Desktop/pyinstaller-develop/main/build/main/out00-PYZ.pyz/pkg_resources", line 115, in get_supported_platform
  File "/Users/michkapopoff/Desktop/pyinstaller-develop/main/build/main/out00-PYZ.pyz/pkg_resources", line 227, in _macosx_vers
  File "/Users/michkapopoff/Desktop/pyinstaller-develop/main/build/main/out00-PYZ.pyz/platform", line 809, in mac_ver
  File "/Users/michkapopoff/Desktop/pyinstaller-develop/main/build/main/out00-PYZ.pyz/platform", line 786, in _mac_ver_xml
  File "/Users/michkapopoff/Desktop/pyinstaller-develop/main/build/main/out00-PYZ.pyz/plistlib", line 78, in readPlist
  File "/Users/michkapopoff/Desktop/pyinstaller-develop/main/build/main/out00-PYZ.pyz/plistlib", line 406, in parse
  File "/Users/michkapopoff/Desktop/pyinstaller-develop/main/build/main/out00-PYZ.pyz/plistlib", line 418, in handleEndElement
  File "/Users/michkapopoff/Desktop/pyinstaller-develop/main/build/main/out00-PYZ.pyz/plistlib", line 452, in end_key
  File "/Users/michkapopoff/Desktop/pyinstaller-develop/main/build/main/out00-PYZ.pyz/plistlib", line 436, in getData
LookupError: no codec search functions registered: can't find encoding
logout

comment:16 Changed 12 months ago by matysek

Hi chris,

could you please provide code example since you were experiencing this issue on another OS?

comment:17 Changed 12 months ago by hisaha

I have same problem. and I added the line

import encodings

to line 10 of
pyinstaller/PyInstaller/loader/rthooks/pyi_rth_pkgres.py

it seems to be solved...

pyinstaller/PyInstaller/loader/rthooks/pyi_rth_pkgres.py

finally like

10 import encodings
11 import pkg_resources as res
12 from pyi_importers import FrozenImporter

hope this help.

comment:18 Changed 12 months ago by anonymous

Okay I just tested, then I got :

Traceback (most recent call last):
  File "<string>", line 26, in <module>
  File "/Users/michkapopoff/Desktop/pyinstaller-develop/PyInstaller/loader/pyi_importers.py", line 270, in load_module
    exec(bytecode, module.__dict__)
  File "/Users/michkapopoff/Desktop/pyinstaller-develop/main/build/main/out00-PYZ.pyz/PIL.PpmImagePlugin", line 27, in <module>
LookupError: no codec search functions registered: can't find encoding

I then added import encodings to pyinstaller/PyInstaller/loader/rthooks/pyi_rth_PIL_Image.py and it worked !!!!

Perhaps I have to do it also with PIL because I am using Pillow (a PIL fork) instead of PIL ?

So I think you found the solution, hisaha. Thanks !

comment:19 follow-up: Changed 11 months ago by mentronome@…

I added

import encodings

to pyinstaller/PyInstaller/loader/rthooks/pyi_rth_pkgres.py

and got past this error too. Perhaps this import could be added to dev codebase

comment:20 in reply to: ↑ 19 Changed 11 months ago by matysek

Replying to mentronome@…:

I added

import encodings

to pyinstaller/PyInstaller/loader/rthooks/pyi_rth_pkgres.py

and got past this error too. Perhaps this import could be added to dev codebase

Is it necessary to put 'import encodings' into pyi_rth_pkgres.py or could it be also in your code or somewhere else?

comment:21 Changed 11 months ago by anonymous

I tested to put it in my code

#!/usr/bin/env python

import encodings
import matplotlib.pyplot as plt

def main():
    x = range(0, 10)
    plt.plot(x)
    plt.draw()
    plt.show()
    
if __name__ == "__main__":
    main()

But it will not work, same error as before.

To sum up, I had to add import encodings in these two files:

  • pyi_rth_pkgres.py
  • pyi_rth_PIL_Image.py

comment:22 Changed 11 months ago by matysek

Could everyone experiencing this issue try my branch if it fixes the encodings issue? https://github.com/matysek/pyinstaller

comment:23 Changed 11 months ago by Michka Popoff <michkapopoff@…>

Works for me ! (Forgot my email adress in the last message)

comment:24 Changed 11 months ago by matysek

  • Keywords encodings codec codecs added
  • Milestone set to PyInstaller 2.1
  • Type changed from support to defect
  • Version changed from 2.0 to develop

It will be fixed in the main tree with the following merge request: https://github.com/pyinstaller/pyinstaller/pull/61

Thanks for testing.

The issue is that statement 'import encodings' has to be before importing any python code. This was implemented as run-time hook. However, this statement is required for some run-time hooks. The order of run-time hooks is not defined. This statement has to be part of the bootstrap code.

comment:25 Changed 11 months ago by matysek

  • Resolution set to fixed
  • Status changed from new to closed

Fix is available in the main development tree.

Add Comment

Modify Ticket

Action
as closed .
The resolution will be deleted. Next status will be 'reopened'.
Author


E-mail address and user name can be saved in the Preferences.

 
Note: See TracTickets for help on using tickets.