3

I'm a learner of Python. There is a problem on executing my script. It shows failed to execute script while packing by Pyinstaller due to

ModuleNotFoundError: No module named 'pandas._libs.tslibs.timedeltas'.

How can I solve it?

I'm using Python 3.6, Pyinstaller 3.4, running on Windows 10.

1201ProgramAlarm
  • 32,384
  • 7
  • 42
  • 56
Sam Kuan
  • 81
  • 2
  • 5

2 Answers2

1

Navigate to your pyinstaller folder, within your Python folder - where it was installed. It might be a path similar to this:

C:\Users\yourName\AppData\Local\Programs\Python\Python36-32\Lib\site-packages\PyInstaller\hooks

In this folder, find the file named hook.pandas.py if it is not in the folder, you will need to create it. Open your IDE or wherever you've been writing your Python scripts and create a new file. This is exactly what your hook-pandas.py should look like:

hiddenimports = ['pandas._libs.tslibs.timedeltas']

That single line is all you need. No need to edit or create anything else. Save, close and attempt to compile using Pyinstaller again. The added benefit of this method is that you do not need to edit every spec file you create when working on other programs.

NL23codes
  • 1,181
  • 1
  • 14
  • 31
0

OK after having the same problem I've found the solution.

In your .spec file edit the hiddenimport to add the following:

hiddenimport=[
    #all your previous hidden imports
    'pandas', 'pandas._libs.tslibs.timedeltas'
]

If you still have an error message (like me) related to scipy this time add the following:

hiddenimport=[
    #all your previous hidden imports
    'pandas', 'pandas._libs.tslibs.timedeltas'
    'scipy', 'scipy._lib.messagestream'
]

Hopefully your script should be good to go!

source of the scipy fix: here

zbgn
  • 5
  • 5