How do I run or compile Cython? So far I have been unable to do either.
Some background:
Windows XP, 32-bit machine
downloaded Python (x,y) 2.7.2.3 (http://code.google.com/p/pythonxy/wiki/Downloads)
I checked the boxes in the python package that would included Cython 0.16 and the MinGW compiler in the installation
I try to follow the steps in this Cython tutorial (http://docs.cython.org/src/userguide/tutorial.html) but get errors. The tutorial does not specify where these steps should be performed, maybe it doesn't matter?
1) I open up IDLE and write:
print "hello world"
2) I save this program as helloworld.pyx, and then close IDLE
3) I reopen IDLE and type the following lines:
>>> from distutils.core import setup
>>> from distutils.extension import Extension
>>> from Cython.Distutils import build_ext
>>> setup(
cmdclass = {'build_ext': build_ext},
ext_modules = [Extension("helloworld",["helloworld.pyx"])]
)
4) after pressing enter I get the following error:
Traceback (most recent call last):
File "<pyshell#6>", line 3, in <module>
ext_modules = [Extension("helloworld",["helloworld.pyx"])]
File "C:\Python27\lib\distutils\core.py", line 140, in setup
raise SystemExit, gen_usage(dist.script_name) + "\nerror: %s" % msg
SystemExit: usage: [global_opts] cmd1 [cmd1_opts] [cmd2 [cmd2_opts] ...]
or: --help [cmd1 cmd2 ...]
or: --help-commands
or: cmd --help
error: no commands supplied
from distutils.core import setup from distutils.extension import Extension from Cython.Distutils import build_ext setup( cmdclass = {'build_ext': build_ext}, ext_modules = [Extension("helloworld", ["helloworld.pyx"])] )
5) If I go onto the next step and type:
$ python setup.py build_ext --inplace
Then I get a syntax error on the dollar sign
What is going on? I get the same errors if I do steps 3-5 in the cmd.exe Shell.
An alternative method to skip steps 3-5 is to type:
>>> import pyximport; pyximport.install()
>>> import helloworld
(I do this in IDLE)
and the result is a long list of errors.
What is going on???
I tried it, and it works. YES!!! lol. Thanks for highlighting those crucial details, it was a big help.