0

I'm trying to install cython and i'm having problems installing the c++ compiler. I have setup.py and main.pyx

setup.py

from setuptools import setup
from Cython.Build import cythonize

setup(
    name="My hello app",
    ext_modules=cythonize("*.pyx", compiler_directives={'always_allow_keywords': True}),

)

when i try to build the main extension, i do python setup.py build_ext --inplace and get this error:

running build_ext
building 'main' extension
cl.exe /c /nologo /O2 /W3 /GL /DNDEBUG /MD -IC:\Users\xxx\AppData\Local\Programs\Python\Python310\include -IC:\Users\xxx\AppData\Local\Programs\Python\Python310\Include /Tcmain.c /Fobuild\temp.win-amd64-cpython-310\Release\main.obj
error: command 'cl.exe' failed: None

I have MinGW/bin added in path.

In this answer someone suggested:

Then, instead of the normal Command Prompt or PowerShell, use one of the special command prompts in the Visual Studio folder in Start Menu. This sets up PATH automatically, so that cl.exe can be found. For 32-bit Python, use x86 Native Tools Command Prompt. For 64-bit Python, use x64 Native Tools Command Prompt.

And so i tried it, however when i tried to open any of the Native Tools Command Prompt i got an error Windows couldn't find cmd.exe.

I tried reinstalling and repairing visual studio build tools 2022 but with no sucess. I very desperate now so i would appreciate any kind of help.

Such Max
  • 35
  • 5
  • Have you tried editing your environment variables manually before ? the missing cmd problem is serious, and your path may be missing system32, so check if it is there – Ahmed AEK Aug 20 '22 at 21:37
  • I checked and all system32 paths are there – Such Max Aug 21 '22 at 06:41
  • while i am sure a clean installation of windows will fix this issue, you can try [repairing windows files](https://support.microsoft.com/en-us/topic/use-the-system-file-checker-tool-to-repair-missing-or-corrupted-system-files-79aa86cb-ca52-166a-92a3-966e85d4094e) and messing around with the paths, there's definitely some broken path somewhere that is causing visual studio build tools to not find cmd and python to not find build tools, note that the script that starts the native tools is a bat file somewhere inside visual studio. – Ahmed AEK Aug 21 '22 at 08:50
  • I tried repairing, said it found some corrupt files and fixed them, Im still getting the same errors however. What i found strange is that when i tried to open any of the .bat files in vs, it said 'windows couldn't find ', so i tried to run it as administrator it opened cmd and said ' isn't recognized as batch file' or something in those lines. It's super weird – Such Max Aug 21 '22 at 12:49

1 Answers1

0

Ok, after around 10 hours of pain and struggling i found out the problem, It was In the enviroment variables. the ComSpec one points to the cmd, and i had an extra semicolon there for some reason, so i manually added cmd.exe and everything works now... So yeah, one stupid semicolon took away 10 hours of my life.

Such Max
  • 35
  • 5
  • Keep programming in C++ and i am sure this won't be the only time a semicolon is taking 10 hours of your life. – Ahmed AEK Aug 21 '22 at 18:18