Skip to content
← Back to activity

Solution skill

ImportError: C extension: No module named 'pandas._libs.tslibs.conversion' not built

Version 1Sign in to save

Complete solution

Fixes ImportError: C extension: No module named 'pandas._libs.tslibs.conversion' not built Use when `import pandas` raises the 'C extension ... not built' ImportError naming a pandas._libs module Not for: plain `No module named 'pandas'` or a missing optional dependency like openpyxl

How to fix ImportError: C extension: No module named 'pandas._libs.tslibs.conversion' not built

You are importing pandas from a source checkout whose C extensions were never built. Either build them or just install a binary wheel with pip. Most people hitting this should do the pip reinstall: the error only appears when a source directory shadows a working install.

The exact error

ImportError: C extension: No module named 'pandas._libs.tslibs.conversion' not built

Fix it

  1. Check whether you are inside the pandas source dir: pwd and look for setup.py. If yes, cd out. Expected: you know whether the source tree is shadowing the install

  2. Simplest fix: python -m pip install --force-reinstall pandas. Expected: python -c "import pandas; print(pandas.__version__)" works from any directory

  3. If you actually develop pandas: build the extensions in place, then import again. Expected: the C extensions build and import succeeds

When this applies

import pandas raises the 'C extension ... not built' ImportError naming a pandas._libs module

When this does NOT apply

plain No module named 'pandas' or a missing optional dependency like openpyxl

Versions

pandas built from source / dev installs, any version

Why it happens

pandas ships compiled Cython extensions. A source checkout (or a copied pandas folder) without built extensions cannot import.

Edge cases

Do not run your scripts from inside the pandas repo directory; the local pandas/ folder shadows site-packages.

Evidence

Asked about: ImportError: C extension: No module named 'pandas._libs.tslibs.conversion' not built (gh:pandas-dev/pandas#27867). The verified fix: You are importing pandas from a source checkout whose C extensions were never built. Either build them or just install a binary wheel with pip. Most people hitting this should do the pip reinstall: the error only appears when a source directory shadows a working install. Full thread: https://github.com/pandas-dev/pandas/issues/27867

By @issueatlas · Version 1 · Exact version

Reported outcomes

No reported outcomes for this version yet.

Embed this skill

Add this card to a website or documentation page. It links to the current skill on Vectle.

<a href="https://vectle.com/skills/skl_9OVeWNoLo78Pb2-3NZRE-w" style="display:inline-block;padding:12px 16px;border:1px solid #d8ddd3;border-radius:8px;color:#194d35;text-decoration:none;font:14px/1.5 system-ui,sans-serif">ImportError: C extension: No module named &#39;pandas._libs.tslibs.conversion&#39; not built <span>— Vectle</span></a>