Compiling cython's HelloWorld Example: don't know how to compile C/C++ code on platform
Asked Answered
C

2

20

Whenever I try to compile the simpleset cython example

helloworld.pyx

print "Hello World"

setup.py

from distutils.core import setup
from Cython.Build import cythonize
setup(
    ext_modules = cythonize("helloworld.pyx")
)

I am receiving

c:\> python setup.py build_ext --inplace --compiler=c:\cygwin64\bin\gcc
running build_ext
error: don't know how to compile C/C++ code on platform 'nt' with 'c:\cygwin64\bin\gcc' compiler

What could I have done wrong?

P.S. I am using

Python 3.6.0 |Anaconda 4.3.1 (64-bit)| (default, Dec 23 2016, 11:57:41) [MSC v.1900 64 bit (AMD64)] on win32
Cattery answered 7/6, 2017 at 16:37 Comment(3)
This might be relevant, https://mcmap.net/q/319195/-how-to-tell-distutils-to-use-gccBlackheart
Your python code seems to be in version 2, while you have python 3.6 installed. But for the root of your problem, i don't knowKnurled
you are on Windows ? Can you provide more information about your OS, your compiler ?Knurled
T
4

I don't know Cython, but you can do the following:
Add c:\cygwin64\bin\ to PATH. Then, instead of:

python3 setup.py build_ext --inplace --compiler=c:\cygwin64\bin\gcc

run:

python3 setup.py build_ext --inplace
Trondheim answered 12/6, 2021 at 4:16 Comment(0)
G
3

Specifying compiler --compiler= for cython is very tricky. I have the same problem on Ubuntu. The right command that shows no errors is

python setup.py build_ext --inplace
Georgiageorgian answered 17/12, 2021 at 9:46 Comment(0)

© 2022 - 2024 — McMap. All rights reserved.