简体   繁体   中英

Cython installation does not find the Python.h file?

I wanted to install cython on my ubuntu 12.04 and I entered in the terminal

sudo easy_install cython

in response, I get the following error:

Searching for cython  
Reading http://pypi.python.org/simple/cython/  
Reading http://www.cython.org  
Reading http://cython.org  
Best match: Cython 0.16  
Downloading http://www.cython.org/release/Cython-0.16.zip  
Processing Cython-0.16.zip  
Running Cython-0.16/setup.py -q bdist_egg --dist-dir /tmp/easy_install-VzJ0lH/Cython-0.16/egg-dist-tmp-BMJs3p  
Compiling module Cython.Plex.Scanners ...  
Compiling module Cython.Plex.Actions ...  
Compiling module Cython.Compiler.Lexicon ...  
Compiling module Cython.Compiler.Scanning ...  
Compiling module Cython.Compiler.Parsing ...  
Compiling module Cython.Compiler.Visitor ...  
Compiling module Cython.Compiler.FlowControl ...  
Compiling module Cython.Compiler.Code ...  
Compiling module Cython.Runtime.refnanny ...  
warning: no files found matching '*.pyx' under directory 'Cython/Debugger/Tests'  
warning: no files found matching '*.pxd' under directory 'Cython/Debugger/Tests'  
warning: no files found matching '*.h' under directory 'Cython/Debugger/Tests'  
warning: no files found matching '*.pxd' under directory 'Cython/Utility'  
warning: no files found matching '*.h' under directory 'Cython/Utility'  
warning: no files found matching '.cpp' under directory 'Cython/Utility'  
/tmp/easy_install-VzJ0lH/Cython-0.16/Cython/Plex/Scanners.c:4:20: fatal error: Python.h: El fitxer o directori no existeix  
compilation terminated.  
error: Setup script exited with error: command 'gcc' failed with exit status 1  

sorry for the catalan in here but El fitxer o directori no existeix means that the file doesn't exist

i think that i perhaps miss something or i don't know

does anyone else have the same problem? or know how to install it correctly?

depending on how you installed python, you may need to get the dev files as well (if you installed with apt-get or Synaptic).

sudo apt-get install python-dev

or maybe

sudo apt-get install python2.6-dev  #substitute your python version here...

Note that this is necessary if you need to install any C extensions to Cpython.

I remember having this problem when installing Cython. If you go to your Python installation folder (assuming Python2.7 for this example), copy the C:\\Python27\\include directory and all of its contents to your home directory or the directory where you're running easy_install. The "include" directory contains "python.h", which is the C header file for the compiler.

That being said, when I did that it eliminated that error, but still didn't work.

Bona sort.

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM