1

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:

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.

Harshit
  • 1,381
  • 15
  • 40
  • And is there a helloworld.c or not? – ead Mar 16 '20 at 19:18
  • No, there is no helloworld.c or helloworld.obj. 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") ) """ – George Bitsonis Mar 16 '20 at 19:26
  • The log should start with something like "[1/1] Cythonizing helloworld.pyx", normally cython doesn't run if it thinks the c-file is up-to-date. FWIW i have no problems with Cython 0.29.11 on windows. – ead Mar 17 '20 at 07:29
  • Well I'm at a stalemate. I will try to run it from PowerShell and see if that makes a difference. Thank you anyways. – George Bitsonis Mar 17 '20 at 11:24

0 Answers0