I am trying to use the numba Python package to compile a simple function ahead-of-time. I have Python version 3.8.5, numba version 0.51.2 and I code in Jupyter notebook version 6.1.4.
The code I am trying to compile is taken from the numba documentation, and is repeated below.
from numba.pycc import CC
cc = CC('my_module')
# Uncomment the following line to print out the compilation steps
#cc.verbose = True
@cc.export('square', 'f8(f8)')
def square(a):
return a ** 2
if __name__ == "__main__":
cc.compile()
It doesn't work, and I get the following error:
DistutilsExecError: Command "C:\Program Files (x86)\Microsoft Visual Studio\2022\BuildTools\VC\Tools\MSVC\14.30.30705\bin\HostX86\x64\cl.exe /c /nologo /Ox /W3 /GL /DNDEBUG /MD -DPYCC_MODULE_NAME=my_module -DPYCC_USE_NRT=1 -IC:\ProgramData\Anaconda3\include -IC:\ProgramData\Anaconda3\include -IC:\\Users\\erera\\AppData\\Roaming\\Python\\Python38\\site-packages\\numpy\\core\\include -IC:\Program Files (x86)\Microsoft Visual Studio\2022\BuildTools\VC\Tools\MSVC\14.30.30705\include /TcC:\ProgramData\Anaconda3\lib\site-packages\numba\pycc\modulemixin.c /FoC:\Users\erera\AppData\Local\Temp\pycc-build-my_module-gxkjko2h\ProgramData\Anaconda3\lib\site-packages\numba\pycc\modulemixin.obj" failed with exit status 2
I am not sure what the issue is, and couldn't find much information on it. I should mention that earlier I had the error:
Attempted to compile AOT function without the compiler used by `numpy.distutils` present. Cannot find suitable msvc.
which disappeared after I installed the Visual Studio Build Tools. Any advice on how to solve this?
Thanks in advance!
CodePudding user response:
