2017-11-15 9 views
2

PyInstaller(開発版)を使用しているexeにPythonスクリプトをラップしようとしています。PyInstallerの 'pandas._libs.tslibs.timedeltas'というモジュールがありません

このスクリプトはPandasを使用しており、exeを実行するとエラーが発生しています。

Traceback (most recent call last): File "site-packages\pandas\__init__.py", line 26, in <module> File "C:\Users\Eddie\Anaconda3\lib\site-packages\PyInstaller\loader\pyimod03_importers.py", line 631, in exec_module 
    exec(bytecode, module.__dict__) File "site-packages\pandas\_libs\__init__.py", line 4, in <module> File "C:\Users\Eddie\Anaconda3\lib\site-packages\PyInstaller\loader\pyimod03_importers.py", line 714, in load_module 
    module = loader.load_module(fullname) File "pandas/_libs/tslib.pyx", line 1, in init pandas._libs.tslib ModuleNotFoundError: No module named 'pandas._libs.tslibs.timedeltas' 

During handling of the above exception, another exception occurred: 

Traceback (most recent call last): File "G5k Version file Extract (with tkinter).py", line 15, in <module> File "C:\Users\Eddie\Anaconda3\lib\site-packages\PyInstaller\loader\pyimod03_importers.py", line 631, in exec_module 
    exec(bytecode, module.__dict__) File "site-packages\pandas\__init__.py", line 35, in <module> ImportError: C extension: No module named 'pandas._libs.tslibs.timedeltas' not built. If you want to import pandas from the source directory, you may need to run 'python setup.py build_ext --inplace --force' to build the C extensions first. 

私はパンダのないプログラムでこれをやってみましたが、すべてうまくいきました。

これは既にPython 2で解決されたanother questionと非常によく似ていますが、私はPython 3を使用しています。その解決方法は変更された.specファイル形式のため同じ方法を適用しません。

のPython 3.6
pyInstallerの - バージョン3.3
パンダ - バージョン0.20.3

答えて

2

私はそれはあなたを助けることはよく分からないが、あなたは3.3 pyInstallerののpython 3.6で私のために仕事を言及ポストのソリューション次およびWindows 7

のパンダ0.21.0は、だから、分析後にspecファイルにこれを追加する:

def get_pandas_path(): 
    import pandas 
    pandas_path = pandas.__path__[0] 
    return pandas_path 

dict_tree = Tree(get_pandas_path(), prefix='pandas', excludes=["*.pyc"]) 
a.datas += dict_tree 
a.binaries = filter(lambda x: 'pandas' not in x[0], a.binaries) 

また、私のspecファイル形式は番目ですe the post you mentionのものと同じです。

14

PyInstaller 3.3、Pandas 0.21.0、Python 3.6.1。

これは、PyInstallerにまだ公表されていない/コミット済みの修正のおかげで解決できました。thisthisを参照してください。それを1つの実行可能ファイルにパックする機能を維持します。

Basicly:

  1. 例えば、.. \フックをpyInstallerのフォルダを探しますC:\Program Files\Python\Lib\site-packages\PyInstaller\hooks。それ保存

    hiddenimports = ['pandas._libs.tslibs.timedeltas'] 
    
  2. +私は、.specファイルを削除し、構築フォルダおよびdistフォルダは、念のために:

  3. (あなたの誤差に基づいてまたは類似のもの)の内容のファイルをhook-pandas.pyを作成します。 pyinstaller -F my_app.py.

  • 実行して、この修正は、限り、あなたはpyInstallerのアップグレードまたは再インストールしていないとして動作するはずです。したがって、.specファイルを編集する必要はありません。

    多分、彼らは私たちのためにすぐに修正を含むでしょう! :)

  • +0

    これは、私のために働いた最初の解決策でした、よく行わ – Harlekuin

    +0

    男、ありがとう、あなたはupvote以上の価値がある...!何日ものデバッグのために私を救ってください –

    関連する問題