복붙노트

[PYTHON] PyInstaller에 'pandas._libs.tslibs.timedeltas'라는 모듈이 없습니다.

PYTHON

PyInstaller에 'pandas._libs.tslibs.timedeltas'라는 모듈이 없습니다.

Windows 용 PyInstaller (개발 버전)를 사용하여 Python 스크립트를 exe에 랩핑하려고합니다.

이 스크립트는 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.

나는 판다없이 프로그램을 위해 이것을 시도하고 모든 것이 좋았다.

이것은 파이썬 2에서 이미 해결 된 다른 질문과 매우 유사하지만, 파이썬 3을 사용하고 있으며 그 솔루션은 .spec 파일 형식이 변경되어 같은 방식으로 적용되지 않습니다.

파이썬 3.6 PyInstaller - 버전 3.3 팬더 - 버전 0.20.3

해결법

  1. ==============================

    1.PyInstaller 3.3, Pandas 0.21.0, Python 3.6.1.

    PyInstaller 3.3, Pandas 0.21.0, Python 3.6.1.

    PyInstaller에 대한 아직 발표되지 않았거나 커밋 된 픽스 덕분에이 문제를 해결할 수있었습니다. 그것을 하나의 실행 파일로 묶는 기능을 유지합니다.

    원래:

    이 픽스는 PyInstaller를 업그레이드하거나 다시 설치하지 않는 한 계속 작동해야합니다. 따라서 .spec 파일을 편집 할 필요가 없습니다.

    아마 그들은 우리를 위해 빨리 수정을 포함 할 것입니다! :)

  2. ==============================

    2.나는 그것이 당신을 도울 수 있을지 모르겠다 그러나 당신이 나를 위해 python 3.6 pyinstaller 3.3과 pandas 0.21.0 with Windows 7에서 일한다고 언급 한 게시물에 대한 해결책을 따른다.

    나는 그것이 당신을 도울 수 있을지 모르겠다 그러나 당신이 나를 위해 python 3.6 pyinstaller 3.3과 pandas 0.21.0 with Windows 7에서 일한다고 언급 한 게시물에 대한 해결책을 따른다.

    그래서 분석 후 바로 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)
    

    또한 내 스펙 파일 형식은 언급 한 게시물의 파일 형식과 동일합니다.

  3. ==============================

    3.필자는 "--hidden-import"플래그를 사용하여이 문제를 해결했습니다. 잘하면이 스레드를 통해 오는 다른 사람에게 도움이 될 수 있습니다.

    필자는 "--hidden-import"플래그를 사용하여이 문제를 해결했습니다. 잘하면이 스레드를 통해 오는 다른 사람에게 도움이 될 수 있습니다.

    pyinstaller --onefile --hidden-import pandas._libs.tslibs.timedeltas myScript.py
    
  4. from https://stackoverflow.com/questions/47318119/no-module-named-pandas-libs-tslibs-timedeltas-in-pyinstaller by cc-by-sa and MIT license