1

I followed the following steps to replicate the Classical Music Composition Using State Space Models code.

The inference algorithms for this code are in Cython. To run the notebook, first run:

np.get_include(), which will output a sample-path.

Then, in the terminal set export CFLAGS="-I sample-path $CFLAGS". I used Windows equivalent:

set CFLAGS = "-IC:\\Users\\scvan\\AppData\\Local\\Programs\\Python\\Python310\\lib\\site-packages\\numpy\\core\\include%CFLAGS%"

Finally, in the terminal, run

python setup.py build_ext --inplace

However, when I try to run the build_ext command I keep getting the following error:

building 'BaumWelch' extension
"C:\Program Files\Microsoft Visual Studio\2022\Community\VC\Tools\MSVC\14.32.31326\bin\HostX86\x64\cl.exe" /c /nologo /O2 /W3 /GL /DNDEBUG /MD "-IC:\Program Files\WindowsApps\PythonSoftwareFoundation.Python.3.10_3.10.1264.0_x64__qbz5n2kfra8p0\include" "-IC:\Program Files\WindowsApps\PythonSoftwareFoundation.Python.3.10_3.10.1264.0_x64__qbz5n2kfra8p0\Include" "-IC:\Program Files\Microsoft Visual Studio\2022\Community\VC\Tools\MSVC\14.32.31326\ATLMFC\include" "-IC:\Program Files\Microsoft Visual Studio\2022\Community\VC\Tools\MSVC\14.32.31326\include" "-IC:\Program Files (x86)\Windows Kits\10\include\10.0.22000.0\ucrt" "-IC:\Program Files (x86)\Windows Kits\10\\include\10.0.22000.0\\shared" "-IC:\Program Files (x86)\Windows Kits\10\\include\10.0.22000.0\\um" "-IC:\Program Files (x86)\Windows Kits\10\\include\10.0.22000.0\\winrt" "-IC:\Program Files (x86)\Windows Kits\10\\include\10.0.22000.0\\cppwinrt" /TcBaumWelch.c /Fobuild\temp.win-amd64-cpython-310\Release\BaumWelch.obj
BaumWelch.c
BaumWelch.c(711): fatal error C1083: Cannot open include file: 'numpy/arrayobject.h': No such file or directory
error: command 'C:\\Program Files\\Microsoft Visual Studio\\2022\\Community\\VC\\Tools\\MSVC\\14.32.31326\\bin\\HostX86\\x64\\cl.exe' failed with exit code 2

To my knowledge, I have installed all the correct build tools in Visual Studio. Maybe I have used the wrong Windows equivalent for expor CFLAGS, can anybody help me out?

Sara
  • 11
  • 2
  • That's not a Windows vs. some other OS issue. It's a tool that interprets this flag, like e.g. `make`. You need to find out what that tool is and why uses the environment var and doesn't on a different system. – Ulrich Eckhardt May 24 '22 at 11:01
  • I am quite inexperienced with programming, could you maybe clarify a bit more? @UlrichEckhardt – Sara May 24 '22 at 12:32
  • @Sara can you share your `setup.py`? (or at least the call to the `setup` function). This `numpy.get_include()` step is common in Cython libraries using Numpy, but there are other ways to set it without resorting to `CFLAGS`. – ibarrond May 24 '22 at 13:47

1 Answers1

0

I fixed the problem by adding include_dirs = [numpy.get_include()] to the setup.py file:

from distutils.core import setup
from Cython.Build import cythonize
import numpy

setup(
 name = 'Baum Welch Code',
 ext_modules = cythonize("BaumWelch.pyx"),
 include_dirs = [numpy.get_include()]
)
Sara
  • 11
  • 2