1

文字通り、役立つグーグル検索は何も見つかりませんでした。py2exe でも pyinstaller を使いたいです。

私の問題は、モジュール (pymunk[aka Chipmunk]) が exe ビルドに完全に含まれていないことです。ある種のdllが欠落している可能性があります。基本的に、解決方法がわからない依存関係がありません。

Failed to load pymunk library.

This error usually means that you don't have a compiled version of chipmunk in
the correct spot where pymunk can find it. pymunk does not include precompiled
chipmunk library files for all platforms.

The good news is that it is usually enough (at least on *nix and OS X) to
simply run the compile command first before installing and then retry again:

You compile chipmunk with
> python setup.py build_chipmunk
and then continue as usual with
> python setup.py install
> cd examples
> python basic_test.py

(for complete instructions please see the readme file)

If it still doesnt work, please report as a bug on the issue tracker at
http://code.google.com/p/pymunk/issues
Remember to include information about your OS, which version of python you use
and the version of pymunk you tried to run. A description of what you did to
trigger the error is also good. Please include the exception traceback if any
(usually found below this message).

Traceback (most recent call last):
  File "<string>", line 2, in <module>
  File "C:\python26\lib\site-packages\PyInstaller\loader\iu.py", line 386, in importHook
    mod = _self_doimport(nm, ctx, fqname)
  File "C:\python26\lib\site-packages\PyInstaller\loader\iu.py", line 480, in doimport
    exec co in mod.__dict__
  File ".\build\pyi.win32\CollisionUtil\out00-PYZ.pyz\pymunk", line 53, in <module>
  File "C:\python26\lib\site-packages\PyInstaller\loader\iu.py", line 431, in importHook
    mod = self.doimport(nm, ctx, ctx + '.' + nm)
  File "C:\python26\lib\site-packages\PyInstaller\loader\iu.py", line 480, in doimport
    exec co in mod.__dict__
  File ".\build\pyi.win32\CollisionUtil\out00-PYZ.pyz\pymunk._chipmunk", line 14, in <module>
  File ".\build\pyi.win32\CollisionUtil\out00-PYZ.pyz\pymunk.libload", line 68, in load_library
  File ".\build\pyi.win32\CollisionUtil\out00-PYZ.pyz\ctypes", line 431, in LoadLibrary
  File ".\build\pyi.win32\CollisionUtil\out00-PYZ.pyz\ctypes", line 353, in __init__
WindowsError: [Error 126] The specified module could not be found

Chipmunk ライブラリは ctypes モジュールを介してラップされているため、これらのメッセージが Chipmunk から送信される限り、コンパイルされていると想定されます。これは、Pythonの観点では役に立ちません。そうでないかもしれない。

pyinstaller のこの依存関係を修正する方法を教えてもらえますか?

4

2 に答える 2

5

chipmunk.dll ファイルを含める必要があります (osx で実行する場合は .dylib ファイル、Linux の場合は .so ファイル)。簡単なハック オプションの 1 つは、生成された .exe ファイルがある場所に手動でコピーすることです。もう1つのオプションは、pyinstallerにそれを含めることです。私は pyinstaller の専門家ではありませんが、それを行う 1 つの方法は、pyinstaller が作成する .spec ファイルを編集することです。

何かのようなもの:

import os, pymunk
pymunk_dir = os.path.dirname(pymunk.__file__)
chipmunk_libs = [
    ('chipmunk.dll', os.path.join(pymunk_dir, 'chipmunk.dll'), 'DATA'),
]
#... 
coll = COLLECT(exe,
               a.binaries + chipmunk_libs,
               a.zipfiles,
               a.datas,
               strip=None,
               upx=True,
               name=os.path.join('dist', 'basic_test'))

完全な例を作成し、pymunk トランクにコミットしました。https://github.com/viblo/pymunk/blob/master/examples/pyinstaller_basic_test.specを見てください(この例では、sys.path.insert(0 ,'..'). あなたのプログラムがすでに pymunk を見つけることができ、仕様ファイルを同じ場所に置くと、その部分は必要ありません。

于 2013-02-17T17:31:55.957 に答える