No module named 'pandas._libs.tslibs.timedeltas' in PyInstaller

PyInstaller 3.3, Pandas 0.21.0, Python 3.6.1.

I was able to solve this thanks to not-yet published/committed fix to PyInstaller, see this and this. AND keeping the ability to pack it into one executable file.

Basically:

  1. Locate PyInstaller folder..\hooks, e.g. C:\Program Files\Python\Lib\site-packages\PyInstaller\hooks.

  2. Create file hook-pandas.py with contents (or anything similar based on your error):

    hiddenimports = ['pandas._libs.tslibs.timedeltas']
    
  3. Save it + I deleted .spec file, build and dist folders just to be sure.

  4. Run pyinstaller -F my_app.py.

This fix should work as long as you don't upgrade or reinstall PyInstaller. So you don't need to edit .spec file.

Maybe they will include the fix sooner for us! :)


I'm not sure it may help you but following the solution on the post you mention work for me with python 3.6 pyinstaller 3.3 and pandas 0.21.0 on windows 7.

So adding this to the spec file just after analysis :

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)

Also my spec file format is the same as the one in the post you mention.