Why Do I get an ImportError when building a .exe with pyinstaller?

前端 未结 4 481
北恋
北恋 2020-12-05 12:11

I just created a small GUI program that compiles and works fine in IPython, but when I try to export it to a .exe using pyinstaller it gives me an import error.

4条回答
  •  执念已碎
    2020-12-05 12:37

    Find this dir "E:\Anaconda3\Lib\site-packages\PyInstaller\hooks". Add a file "hook-pandas.py",wrie this content to this file:

    """
    Hook for pandas. 
    Suport for pyinstaller error : No module named ‘pandas._libs.tslibs.timedeltas
    """
    hiddenimports=[
        #all your previous hidden imports
        'pandas', 'pandas._libs.tslibs.timedeltas',
        'sklearn.neighbors.typedefs'
    ]
    

    Then use this command:

    pyinstaller -F myfile.py --hidden-import sklearn.neighbors.typedefs
    

    Then it will be OK!

提交回复
热议问题