Embedded Python - Errors with Numpy
When I install the numpy package on Python on my PC using:
pip install numpyI can use it in python on my machine. If I do:
pip install --target C:\InterSystems\IRIS\mgr\python numpyI get errors any time I try to import it in embedded python.
Traceback (most recent call last):
File "c:\intersystems\iris\mgr\python\numpy\_core\__init__.py", line 23, in <module>
from . import multiarray
File "c:\intersystems\iris\mgr\python\numpy\_core\multiarray.py", line 10, in <module>
from . import overrides
File "c:\intersystems\iris\mgr\python\numpy\_core\overrides.py", line 8, in <module>
from numpy._core._multiarray_umath import (
ModuleNotFoundError: No module named 'numpy._core._multiarray_umath'
During handling of the above exception, another exception occurred:
Traceback (most recent call last):
File "c:\intersystems\iris\mgr\python\numpy\__init__.py", line 128, in <module>
from numpy.__config__ import show as show_config
File "c:\intersystems\iris\mgr\python\numpy\__config__.py", line 4, in <module>
from numpy._core._multiarray_umath import (
File "c:\intersystems\iris\mgr\python\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.9 from "c:\intersystems\iris\bin\IRISDB.EXE"
* The NumPy version is: "2.1.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 "<input>", line 1, in <module>
File "c:\intersystems\iris\mgr\python\numpy\__init__.py", line 133, 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.Has anyone else run into this and do you know how to fix it?
Comments
Your version of numpy is not compatible with python3.9.
Try to reinstall it with irispython :
irispython -m pip install --target C:\InterSystems\IRIS\mgr\python numpy
Thank you, Guillaume! Lesson learned: make sure you're running pip from the IRIS Python, not the default Python on the PC!
You can use your default python/pip but it needs more works (setup BYOP (bring your on python), make sure that your current user has suffisant privilege to run irisdb, make use of virtual environnement, fix some C library path)
We are running IRIS 2025.1.0.225.1 and we have python 3.12 installed external from IRIS and are receiving the same errors when we try to import numpy. It looks like irispython and irispip is no longer available in 2025.1 and this is the error I received when we I tried running the irispython solution suggested above. Is there something else that could be causing this issue?
This is what we received when we ran the suggested solution.
c:\> irispython -m pip install --target C:\InterSystems\IRIS\mgr\python numpy
'irispython' is not recognized as an internal or external command,
operable program or batch file.