In order to apply Cython to a future project and to familiarize myself with it, I started by creating a simple 'helloworld' as described on Cython's documentation, on a windows machine. After following the instructions I keep getting the same error:
D:\Test GB Python\HelloWorldpyx>python setup.py build_ext --inplace
running build_ext
building 'helloworld' extension
C:\Program Files (x86)\Microsoft Visual Studio\2019\BuildTools\VC\Tools\MSVC\14.24.28314\bin\HostX86\x64\cl.exe /c /nologo /Ox /W3 /GL /DNDEBUG /MD -ID:\Python\include -ID:\Python\include "-IC:\Program Files (x86)\Microsoft Visual Studio\2019\BuildTools\VC\Tools\MSVC\14.24.28314\include" "-IC:\Program Files (x86)\Windows Kits\10\include\10.0.18362.0\ucrt" "-IC:\Program Files (x86)\Windows Kits\10\include\10.0.18362.0\shared" "-IC:\Program Files (x86)\Windows Kits\10\include\10.0.18362.0\um" "-IC:\Program Files (x86)\Windows Kits\10\include\10.0.18362.0\winrt" "-IC:\Program Files (x86)\Windows Kits\10\include\10.0.18362.0\cppwinrt" "-IC:\Program Files (x86)\Microsoft Visual Studio\2019\BuildTools\VC\Tools\MSVC\14.24.28314\include" "-IC:\Program Files (x86)\Windows Kits\10\include\10.0.18362.0\ucrt" "-IC:\Program Files (x86)\Windows Kits\10\include\10.0.18362.0\shared" "-IC:\Program Files (x86)\Windows Kits\10\include\10.0.18362.0\um" "-IC:\Program Files (x86)\Windows Kits\10\include\10.0.18362.0\winrt" "-IC:\Program Files (x86)\Windows Kits\10\include\10.0.18362.0\cppwinrt" /Tchelloworld.c /Fobuild\temp.win-amd64-3.8\Release\helloworld.obj
helloworld.c
c1: fatal error C1083: Cannot open source file: 'helloworld.c': No such file or directory
error: command 'C:\\Program Files (x86)\\Microsoft Visual Studio\\2019\\BuildTools\\VC\\Tools\\MSVC\\14.24.28314\\bin\\HostX86\\x64\\cl.exe' failed with exit status 2**
Trying to figure out on my own the problem, I read, to no avail, the following:
- Error when import c file after cythonize
- Unable to compile cython generated .c file
- Cythonize but not compile .pyx files using setup.py
- https://github.com/cython/cython/wiki/CythonExtensionsOnWindows
- https://wiki.python.org/moin/WindowsCompilers#Which_Microsoft_Visual_C.2B-.2B-_compiler_to_use_with_a_specific_Python_version_.3F
So far I tried:
- Including in the environment variables path, both Python and the VS x64 compiler.
- Downloading and installing the appropriate VS compiler for my Python version.
- Updating setuptools.
- Executing the 'cythonize -3 -i helloworld.pyx' command, both from the Developer Command Promt for VS 2019 and from the x64 Native Tools Command Prompt for VS 2019 as an Administrator.
- Successfully compiling .c and .cpp 'Helloworld' files, written in c and c++ respectfully, on another directory.
- Altering the setup.py, as is written in Cython's documentation, file to include the '# distutils: language=3' in order to specify that Python 3 is in use. So now the 'setup.py' looks like this:
# distutils: language=3
from distutils.core import setup
from Cython.Build import cythonize
setup(
ext_modules = cythonize("helloworld.pyx")
)
The system specifications are:
- Microsoft Windows [Version 10.0.18362.720]
- MSVC 14.24.28314
- Python 3.8.2 AMD64
- Cython 0.29.15
Any help will be much appreciated, I hope not to be a duplicate question and since is my first question here, any editing necessary will be performed as indicated.