2016-04-19 17 views
8

Sto costruendo un pacchetto in Cython. Sto usando la seguente come la struttura per setup.py:Errore di compilazione Cython: il modulo dinamico non definisce la funzione di esportazione modulo

from distutils.core import setup 
from distutils.extension import Extension 
from Cython.Build import cythonize 
import numpy 
import scipy 

extensions = [ 
    Extension("xxxxx",["xxxx/xxxxx.pyx"], 
    include_dirs=[numpy.get_include(),"."]), 
    Extension("nnls",["xxxxx/xxxxx.pyx"], 
       include_dirs=[numpy.get_include(),"."]), 
] 

setup(
    name='xxxxxx', 
    version='0.0.0', 
    description='''********''', 
    url='xxxxxxx', 
    author='xxxxx', 
    author_email='xxxxx', 
    packages=[ 
     'xxxxx', 
    ], 
    install_requires=[ 
     'cython', 
     'numpy', 
     'scipy', 
    ], 
    ext_modules=cythonize(extensions), 
) 

Tuttavia, sto ottenendo un errore durante l'installazione in Python 3. Si sta lavorando in Python 2 tuttavia, non sta compilando in Python 3 avente la seguente errore :

dynamic module does not define module export function

Come posso risolvere questo problema? La struttura di setup.py è la ragione per cui non si sta compilando?

risposta

4

È necessario chiamare setup.py con Python 3 (python3 setup.py build_ext, forse --inplace). È perché Python 3 definisce un nome diverso per la funzione init chiamata all'avvio del modulo e quindi è necessario crearlo utilizzando Python 3 per garantire che venga generato il nome corretto.

Vedi Cython Compilation Error: dynamic module does not define module export function e How to specify Python 3 source in Cython's setup.py? per un po 'più in dettaglio (è confinante con un duplicato di queste domande, ma non è del tutto a mio avviso)

Problemi correlati