Labels

Comments

@Avnsx

Describe the issue:

I require the usage of numpy in combination with opencv-python (any version or the newest one 4.11.0.86). So I was literally just trying to import numpy, on the thread unlocked version of python 3.13.2 (3.13t), but that already makes it error out

Linked: opencv/opencv-python#1029

Reproduce the code example:

import numpy

Error message:

Traceback (most recent call last):
  File "C:\Program Files\Python\Lib\site-packages\numpy\_core\__init__.py", line 23, in <module>
    from . import multiarray
  File "C:\Program Files\Python\Lib\site-packages\numpy\_core\multiarray.py", line 10, in <module>
    from . import overrides
  File "C:\Program Files\Python\Lib\site-packages\numpy\_core\overrides.py", line 7, in <module>
    from numpy._core._multiarray_umath import (
        add_docstring,  _get_implementing_args, _ArrayFunctionDiser)
ModuleNotFoundError: No module named 'numpy._core._multiarray_umath'

During handling of the above exception, another exception occurred:

Traceback (most recent call last):
  File "C:\Program Files\Python\Lib\site-packages\numpy\__init__.py", line 127, in <module>
    from numpy.__config__ import show_config
  File "C:\Program Files\Python\Lib\site-packages\numpy\__config__.py", line 4, in <module>
    from numpy._core._multiarray_umath import (
    ...<3 lines>...
    )
  File "C:\Program Files\Python\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 "C:\Program Files\Python\python3.13t.exe"
  * The NumPy version is: "2.2.2"

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'


The above exception was the direct cause of the following exception:

Traceback (most recent call last):
  File "C:\Users\me\Desktop\code.py", line 1, in <module>
    import numpy
  File "C:\Program Files\Python\Lib\site-packages\numpy\__init__.py", line 132, in <module>
    raise ImportError(msg) from e
ImportError: 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.
[Finished in 83ms]

Python and NumPy Versions:

numpy version 2.2.2
python version 3.13.2 - clicked on experimental version of python with thread unlocked / GIL free in the installer
operating system windows 11 - 64 bit

Runtime Environment:

Was trying to import in Sublime Text 4, which is my main Code Editor

Context for the issue:

It's clearly important that numpy works on all future versions of python!

@AvnsxAvnsx added the 00 - Bug label Feb 4, 2025
@AvnsxAvnsx changed the title BUG: Can't import numpy 2.2.2 on python 3.12.2 BUG: Can't import numpy 2.2.2 on python 3.13.2 Feb 4, 2025
@ngoldbaum

NumPy supports free-threaded Python, we have 313t Windows wheels on pypi.

How did you install NumPy?

@Avnsx

How did you install NumPy?

I was just typing pip install numpy, in windows cmd to install version numpy 2.2.2. Not like I had any other option, when trying to install the wheel, it just wouldn't let me saying it's incompatible

But this may have been an issue with my environment, i think i and my installed libaries such as opencv-python, were accidently trying to access the thread unlocked version of numpy, with thread-locked version 3.13.2, or maybe the other way around...

i got it to work after i installed numpy in the following way through my code editor itsself, which appeared to run the right version of python and installed the right version of numpy:

import subprocess
import sys

def install_package(package_name):
    try:
        subprocess.check_call([sys.executable, '-m', 'pip', 'install', package_name])
    except subprocess.CalledProcessError:
        print(f"Failed to install {package_name}.")
        sys.exit(1)

def main():
    install_package('numpy')
    import numpy as np
    print(f"NumPy version: {np.__version__}")
    print(f"Python version: {sys.version}")

if __name__ == '__main__':
    main()
Collecting numpy
  Downloading numpy-2.2.2-cp313-cp313t-win_amd64.whl.metadata (60 kB)
Downloading numpy-2.2.2-cp313-cp313t-win_amd64.whl (12.7 MB)
   ---------------------------------------- 12.7/12.7 MB 4.0 MB/s eta 0:00:00
Installing collected packages: numpy
Successfully installed numpy-2.2.2
NumPy version: 2.2.2
Python version: 3.13.2 experimental free-threading build (tags/v3.13.2:4f8bb39, Feb  4 2025, 15:33:40) [MSC v.1942 64 bit (AMD64)]
pip 25.0 from C:\Program Files\Python\Lib\site-packages\pip (python 3.13)

@ngoldbaum

I think you're running into python/cpython#127294. Closing since this is unrelated to NumPy.

@charris

We recommend using python -mpip install numpy where python is the desired python version. This is important when you have several python versions installed, there is no telling which python will be used otherwise, it will depend on history.

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

No branches or pull requests