Skip to content

Pandas cannot import numpy in free-threaded version of 3.13.0b2 #120653

Closed
@kdgts

Description

@kdgts

Bug report

Bug description:

  1. Install python 3.13.0b2 on windows 10, make sure to install free-threaded binaries
  2. Go to the python installation directory and install pandas by running:
    python -m pip install pandas
    This will also install numpy
  3. Create file KDTest.py someplace outside of python installation directory with the following content:
from pandas import Timestamp

if __name__ == '__main__':
    t1: Timestamp = Timestamp("2023-11-29")
    print("Done")
  1. Assuming python is installed to C:\apps\python313 run
    C:\apps\python313\python.exe <path to file>/KDTest.py
    Result: all good, Done is printed
  2. Now run:
    C:\apps\python313\python3.13t.exe <path to file>/KDTest.py
    Result:
Traceback (most recent call last):
  File "<path to file>\KDTest.py", line 1, in <module>
    from pandas import Timestamp
  File "C:\apps\python313\Lib\site-packages\pandas\__init__.py", line 19, in <module>
    raise ImportError(
        "Unable to import required dependencies:\n" + "\n".join(_missing_dependencies)
    )
ImportError: Unable to import required dependencies:
numpy: Error importing numpy: you should not try to import numpy from
        its source directory; please exit the numpy source tree, and relaunch
        your python interpreter from there.

CPython versions tested on:

3.13

Operating systems tested on:

Windows

Activity

added
type-bugAn unexpected behavior, bug, or error
on Jun 17, 2024
JamesParrott

JamesParrott commented on Jun 17, 2024

@JamesParrott

This issue should be closed, and reopened in the Numpy and Pandas repos.

The latest release of Numpy, version 2.0.0, came out only yesterday. It does not support Python 3.13.

The Python versions supported by this release are 3.9-3.12
https://numpy.org/devdocs/release/2.0.0-notes.html

Nonetheless, Numpy support for Python 3.13 is actively being worked on: numpy/numpy#26157

@kdgts
There are only bdists on PyPi for Python 3.12 for both Pandas and Numpy,
https://pypi.org/project/pandas/#files
https://pypi.org/project/numpy/#files

Pip will have attempted to build them both, and quite likely silently failed (unless all of the following build dependencies were installed: https://numpy.org/doc/stable/building/index.html).

colesbury

colesbury commented on Jun 17, 2024

@colesbury
Contributor

I think there may be an underlying issue in CPython here where the packages are shared between the free-threaded and default builds in ways that lead to confusing error messages.

@kdgts wrote:

install pandas by running: python -m pip install pandas

But this is installing pandas and numpy packages for the default build (not free-threaded)

You'd want to install them by python3.13t.exe -m pip install pandas

ngoldbaum

ngoldbaum commented on Jun 17, 2024

@ngoldbaum
Contributor
No description provided.
kdgts

kdgts commented on Jun 17, 2024

@kdgts
Author

Well, given that everything works just fine with python13 regular but fails with python13 free-threaded it's pretty obvious that issue is not with numpy or pandas but rather with free-threaded python

JamesParrott

JamesParrott commented on Jun 17, 2024

@JamesParrott

My apologies - it was taking so much longer than normal to install pandas, I assumed pip had hung. But it completed eventually.

I have reproduced the behaviour (after installing pandas into a venv first), and it is the same error as in your post, pretty much verbatim. Moreover, on simply importing numpy:

"%LOCALAPPDATA%\Programs\Python\Python313\python3.13t.exe" -c "import numpy"
Traceback (most recent call last):
  File "%LOCALAPPDATA%\Programs\Python\Python313\Lib\site-packages\numpy\_core\__init__.py", line 23, in <module>
    from . import multiarray
  File "%LOCALAPPDATA%\Programs\Python\Python313\Lib\site-packages\numpy\_core\multiarray.py", line 10, in
 <module>
    from . import overrides
  File "%LOCALAPPDATA%\Programs\Python\Python313\Lib\site-packages\numpy\_core\overrides.py", line 8, in <module>
    from numpy._core._multiarray_umath import (
        add_docstring,  _get_implementing_args, _ArrayFunctionDispatcher)
ModuleNotFoundError: No module named 'numpy._core._multiarray_umath'

During handling of the above exception, another exception occurred:

Traceback (most recent call last):
  File "%LOCALAPPDATA%\Programs\Python\Python313\Lib\site-packages\numpy\__init__.py", line 114, in <module>
    from numpy.__config__ import show as show_config
  File "%LOCALAPPDATA%\Programs\Python\Python313\Lib\site-packages\numpy\__config__.py", line 4, in <module>
    from numpy._core._multiarray_umath import (
    ...<3 lines>...
    )
  File "%LOCALAPPDATA%\Programs\Python\Python313\Lib\site-packages\numpy\_core\__init__.py", line 49, in <module>
    raise ImportError(msg)
ImportError:

IMPORTANT: PLEASE READ THIS FOR ADVICE ON HOW TO SOLVE THIS ISSUE!

Importing the numpy C-extensions failed. This error can happen for
many reasons, often due to issues with your setup or how NumPy was
installed.

We have compiled some common reasons and troubleshooting tips at:

    https://numpy.org/devdocs/user/troubleshooting-importerror.html

Please note and check the following:

  * The Python version is: Python3.13 from "%LOCALAPPDATA%\Programs\Python\Python313\python3.13t.exe"
  * The NumPy version is: "2.0.0"

and make sure that they are the versions you expect.
Please carefully study the documentation linked above for further help.

Original error was: No module named 'numpy._core._multiarray_umath'
lesteve

lesteve commented on Jun 19, 2024

@lesteve
Contributor
No description provided.
rgommers

rgommers commented on Jun 19, 2024

@rgommers
Contributor

I am not sure there are some on Windows right now though

Not yet, Windows is still in the works. Python 3.13.0b2 was the first version that included free-threaded support in Python itself; there is an issue with it in pyconfig.h that needs working around before NumPy can be built. I'm working on that right now actually - it'll be a few weeks at least before the fixes to the build system fixes propagate and Pandas & co can be built as well.

rgommers

rgommers commented on May 16, 2025

@rgommers
Contributor

I think there may be an underlying issue in CPython here where the packages are shared between the free-threaded and default build

This issue was fixed a long time ago, can someone hit the close button please?


I'll note that NumPy has had cp313t wheels for Windows on PyPI for several releases; Pandas hasn't seen a release in a long time and 2.2.3 didn't have Windows wheels; a Pandas nightly wheel can be installed from https://anaconda.org/scientific-python-nightly-wheels/pandas though.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions

      Pandas cannot import numpy in free-threaded version of 3.13.0b2 · Issue #120653 · python/cpython

      Follow Lee on X/Twitter - Father, Husband, Serial builder creating AI, crypto, games & web tools. We are friends :) AI Will Come To Life!

      Check out: eBank.nz (Art Generator) | Netwrck.com (AI Tools) | Text-Generator.io (AI API) | BitBank.nz (Crypto AI) | ReadingTime (Kids Reading) | RewordGame | BigMultiplayerChess | WebFiddle | How.nz | Helix AI Assistant