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! 🙂

Leave a Comment