No Module Named 'Pandas._Libs.Tslibs.Timedeltas' in Pyinstaller

No module named 'pandas._libs.tslib'

I faced a similar issue and solved it by manually uninstalling pandas and then installing pandas using pip. You have mentioned that you have only updated pandas. So I assume you haven't tried re-installing it.

While doing so pandas version in my environment changed from 0.23.4 to 0.24.1

My Environment :

python 3.6.7

pip 18.1

Note : I am also a beginner in Python usage. More experienced users may know a better way.

pip uninstall pandas
pip install pandas

The above steps solved my issues and I am able to import pandas.

I checked the release notes in pandas community and it seems like the dependency on tslib has been removed.
Check section 1.5 in the below link and search for tslib.

http://pandas.pydata.org/pandas-docs/version/0.24/pandas.pdf

Cannot get Pyinstaller to create a standalone with Pandas

I guess you have problem with installation of pandas module.
Try to run command "pip install pandas" first may be your pandas package is not install.
then you can run pyinstaller.

However you can do additional things like setup settings follow below example:

Please fill "install_requires" whatever packages you want.

setup(
name="abcd",
version="1.0.0",
long_description=README,
long_description_content_type="text/markdown",
url="https://github.com/realpython/reader",
author="abcd",
author_email="abcd.com",
license="MIT",
classifiers=[
"License :: OSI Approved :: MIT License",
"Programming Language :: Python",
"Programming Language :: Python :: 2",
"Programming Language :: Python :: 3",
],
packages=["reader"],
include_package_data=True,
install_requires=[
"pandas", "html2text", "importlib_resources", "typing"
],
entry_points={"console_scripts": ["abc=reader.__main__:main"]},
)

pyinstaller ImportError: C extension: No module named np_datetime not built

I ran into the same problem and found this thread, but I managed to solve it borrowing from the reference you posted (about pandas._libs.tslibs.timedeltas), so thank you for that!

In that article, the module that resulted in the ImportError was, in fact pandas._libs.tslibs.timedeltas, if you look at the poster's logs. But the error you and I ran into refers to np_datetime instead. So, from the traceback logs, I finally figured out that the code we have to write in hook-pandas.py should be the following:

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

Maybe that alone will solve your problem, HOWEVER, in my case, once I solved the np_datetime issue, other very similar ImportError problems arose (also related to hiddenimports regarding pandas), so, in case you run into the same issues, just define hiddenimports as follows:

hiddenimports = ['pandas._libs.tslibs.np_datetime','pandas._libs.tslibs.nattype','pandas._libs.skiplist']

TL;DR:

You can first try to write

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

into hook-pandas.py. However, if for some reason you run into the exact same issues I did afterwards, try

hiddenimports = ['pandas._libs.tslibs.np_datetime','pandas._libs.tslibs.nattype','pandas._libs.skiplist']

If you wish to dive deeper (or run into a different pandas ImportError than the ones I did), this is the code in pandas's __init__.py referenced in your traceback log (lines 23 to 35):

from pandas.compat.numpy import *

try:
from pandas._libs import (hashtable as _hashtable,
lib as _lib,
tslib as _tslib)
except ImportError as e: # pragma: no cover
# hack but overkill to use re
module = str(e).replace('cannot import name ', '')
raise ImportError("C extension: {0} 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.".format(module))

From that I went into the

C:\Python27\Lib\site-packages\pandas_libs

and

C:\Python27\Lib\site-packages\pandas_libs\tslibs

folders and found the exact names of the modules that resulted the errors.

I hope that solves your problem as it did mine.

Cheers!



Related Topics



Leave a reply



Submit