distutils bdist_wininst failure on Linux

Discussion in 'Python' started by Steven D'Aprano, Feb 23, 2012.

  1. Following instructions here:

    http://docs.python.org/py3k/distutils/builtdist.html#creating-windows-installers

    I am trying to create a Windows installer for a pure-module distribution
    using Python 3.2. I get a "LookupError: unknown encoding: mbcs"

    Here is the full output of distutils and the traceback:


    [steve@ando pyprimes]$ python3.2 setup.py bdist_wininst
    running bdist_wininst
    running build
    running build_py
    creating build/lib
    copying src/pyprimes.py -> build/lib
    installing to build/bdist.linux-i686/wininst
    running install_lib
    creating build/bdist.linux-i686/wininst
    creating build/bdist.linux-i686/wininst/PURELIB
    copying build/lib/pyprimes.py -> build/bdist.linux-i686/wininst/PURELIB
    running install_egg_info
    Writing build/bdist.linux-i686/wininst/PURELIB/pyprimes-0.1.1a-py3.2.egg-info
    creating '/tmp/tmp3utw4_.zip' and adding '.' to it
    adding 'PURELIB/pyprimes.py'
    adding 'PURELIB/pyprimes-0.1.1a-py3.2.egg-info'
    creating dist
    Warning: Can't read registry to find the necessary compiler setting
    Make sure that Python modules winreg, win32api or win32con are installed.
    Traceback (most recent call last):
    File "setup.py", line 60, in <module>
    "License :: OSI Approved :: MIT License",
    File "/usr/local/lib/python3.2/distutils/core.py", line 148, in setup
    dist.run_commands()
    File "/usr/local/lib/python3.2/distutils/dist.py", line 917, in run_commands
    self.run_command(cmd)
    File "/usr/local/lib/python3.2/distutils/dist.py", line 936, in run_command
    cmd_obj.run()
    File "/usr/local/lib/python3.2/distutils/command/bdist_wininst.py", line 179, in run
    self.create_exe(arcname, fullname, self.bitmap)
    File "/usr/local/lib/python3.2/distutils/command/bdist_wininst.py", line 262, in create_exe
    cfgdata = cfgdata.encode("mbcs")
    LookupError: unknown encoding: mbcs


    How do I fix this, and is it a bug in distutils?



    --
    Steven
     
    Steven D'Aprano, Feb 23, 2012
    #1
    1. Advertising

  2. Steven D'Aprano

    jmfauth Guest

    On 23 fév, 15:06, Steven D'Aprano <steve
    > wrote:
    > Following instructions here:
    >
    > http://docs.python.org/py3k/distutils/builtdist.html#creating-windows...
    >
    > I am trying to create a Windows installer for a pure-module distribution
    > using Python 3.2. I get a "LookupError: unknown encoding: mbcs"
    >
    > Here is the full output of distutils and the traceback:
    >
    > [steve@ando pyprimes]$ python3.2 setup.py bdist_wininst
    > running bdist_wininst
    > running build
    > running build_py
    > creating build/lib
    > copying src/pyprimes.py -> build/lib
    > installing to build/bdist.linux-i686/wininst
    > running install_lib
    > creating build/bdist.linux-i686/wininst
    > creating build/bdist.linux-i686/wininst/PURELIB
    > copying build/lib/pyprimes.py -> build/bdist.linux-i686/wininst/PURELIB
    > running install_egg_info
    > Writing build/bdist.linux-i686/wininst/PURELIB/pyprimes-0.1.1a-py3.2.egg-info
    > creating '/tmp/tmp3utw4_.zip' and adding '.' to it
    > adding 'PURELIB/pyprimes.py'
    > adding 'PURELIB/pyprimes-0.1.1a-py3.2.egg-info'
    > creating dist
    > Warning: Can't read registry to find the necessary compiler setting
    > Make sure that Python modules winreg, win32api or win32con are installed.
    > Traceback (most recent call last):
    >   File "setup.py", line 60, in <module>
    >     "License :: OSI Approved :: MIT License",
    >   File "/usr/local/lib/python3.2/distutils/core.py", line 148, in setup
    >     dist.run_commands()
    >   File "/usr/local/lib/python3.2/distutils/dist.py", line 917, in run_commands
    >     self.run_command(cmd)
    >   File "/usr/local/lib/python3.2/distutils/dist.py", line 936, in run_command
    >     cmd_obj.run()
    >   File "/usr/local/lib/python3.2/distutils/command/bdist_wininst.py", line 179, in run
    >     self.create_exe(arcname, fullname, self.bitmap)
    >   File "/usr/local/lib/python3.2/distutils/command/bdist_wininst.py", line 262, in create_exe
    >     cfgdata = cfgdata.encode("mbcs")
    > LookupError: unknown encoding: mbcs
    >
    > How do I fix this, and is it a bug in distutils?
    >
    > --
    > Steven


    Because the 'mbcs' codec is missing in your Linux, :)

    >>> 'abc需'.encode('cp1252')

    b'abc\xe9\x9c\x80'
    >>> 'abc需'.encode('missing')

    Traceback (most recent call last):
    File "<eta last command>", line 1, in <module>
    LookupError: unknown encoding: missing

    jmf
     
    jmfauth, Feb 23, 2012
    #2
    1. Advertising

  3. On Thu, 23 Feb 2012 07:09:35 -0800, jmfauth wrote:

    > On 23 fév, 15:06, Steven D'Aprano <steve
    > > wrote:
    >> Following instructions here:
    >>
    >> http://docs.python.org/py3k/distutils/builtdist.html#creating-

    windows...
    >>
    >> I am trying to create a Windows installer for a pure-module
    >> distribution using Python 3.2. I get a "LookupError: unknown encoding:
    >> mbcs"

    [...]
    >> How do I fix this, and is it a bug in distutils?

    >
    > Because the 'mbcs' codec is missing in your Linux, :)


    Well duh :)

    This is a bug in distutils. Prompted by your comment I expanded my search
    terms and found this bug report:

    http://bugs.python.org/issue10945

    The problem is that mbcs is not a real codec, it means "whatever codec is
    currently configured in Windows". So it doesn't exist on non-Windows
    platforms. But distutils bdist_wininst is explicitly documented as
    working on non-Windows platforms. Hence, it's a bug.


    --
    Steven
     
    Steven D'Aprano, Feb 24, 2012
    #3
  4. On Fri, 24 Feb 2012 00:11:11 +0000, Steven D'Aprano wrote:

    > On Thu, 23 Feb 2012 07:09:35 -0800, jmfauth wrote:
    >
    >> On 23 fév, 15:06, Steven D'Aprano <steve
    >> > wrote:
    >>> Following instructions here:
    >>>
    >>> http://docs.python.org/py3k/distutils/builtdist.html#creating-

    > windows...
    >>>
    >>> I am trying to create a Windows installer for a pure-module
    >>> distribution using Python 3.2. I get a "LookupError: unknown encoding:
    >>> mbcs"

    > [...]
    >>> How do I fix this, and is it a bug in distutils?

    >>
    >> Because the 'mbcs' codec is missing in your Linux, :)

    >
    > Well duh :)
    >
    > This is a bug in distutils. Prompted by your comment I expanded my
    > search terms and found this bug report:
    >
    > http://bugs.python.org/issue10945
    >
    > The problem is that mbcs is not a real codec, it means "whatever codec
    > is currently configured in Windows". So it doesn't exist on non-Windows
    > platforms. But distutils bdist_wininst is explicitly documented as
    > working on non-Windows platforms. Hence, it's a bug.



    And I have a work-around that seems to work for me. Put this at the top
    of your setup.py install script:



    # Work around mbcs bug in distutils.
    # http://bugs.python.org/issue10945
    import codecs
    try:
    codecs.lookup('mbcs')
    except LookupError:
    ascii = codecs.lookup('ascii')
    func = lambda name, enc=ascii: {True: enc}.get(name=='mbcs')
    codecs.register(func)




    --
    Steven
     
    Steven D'Aprano, Feb 24, 2012
    #4
  5. Steven D'Aprano

    Bob Bowles Guest

    Steven D'Aprano-11 wrote
    >
    > And I have a work-around that seems to work for me. Put this at the top
    > of your setup.py install script:
    >
    >
    >
    > # Work around mbcs bug in distutils.
    > # http://bugs.python.org/issue10945
    > import codecs
    > try:
    > codecs.lookup('mbcs')
    > except LookupError:
    > ascii = codecs.lookup('ascii')
    > func = lambda name, enc=ascii: {True: enc}.get(name=='mbcs')
    > codecs.register(func)
    >
    >

    Nice one, worked first time! Thanks!



    --
    View this message in context: http://python.6.n6.nabble.com/distutils-bdist-wininst-failure-on-Linux-tp4498729p4984209.html
    Sent from the Python - python-list mailing list archive at Nabble.com.
     
    Bob Bowles, Aug 6, 2012
    #5
    1. Advertising

Want to reply to this thread or ask your own question?

It takes just 2 minutes to sign up (and it's free!). Just click the sign up button to choose a username and then you can ask your own questions on the forum.
Similar Threads
  1. Chris Gonnerman
    Replies:
    7
    Views:
    445
    John Machin
    Aug 9, 2003
  2. Peter Schmiedeskamp
    Replies:
    1
    Views:
    553
    Martin v. =?iso-8859-15?q?L=F6wis?=
    Nov 1, 2003
  3. Dominic

    bdist_wininst strangeness

    Dominic, May 6, 2004, in forum: Python
    Replies:
    0
    Views:
    357
    Dominic
    May 6, 2004
  4. timw.google
    Replies:
    1
    Views:
    559
    Serge Orlov
    May 11, 2006
  5. Luis Alberto Zarrabeitia Gomez

    distutils, No module named numpy.distutils.fcompiler.conv_template

    Luis Alberto Zarrabeitia Gomez, Mar 30, 2009, in forum: Python
    Replies:
    0
    Views:
    1,357
    Luis Alberto Zarrabeitia Gomez
    Mar 30, 2009
Loading...

Share This Page