我目前正在尝试对我的部分python代码进行cython化,我有一个名为setupcython.py的文件,它是:
from distutils.core import setup, Extension
from Cython.Distutils import build_ext
import numpy.distutils.misc_util
include_dirs = numpy.distutils.misc_util.get_numpy_include_dirs()
setup(name='clib',
version='1.0',
ext_modules=[Extension('clib', ['clib.pyx'], include_dirs=include_dirs, extra_compile_args=["-O3"])],
cmdclass={'build_ext' : build_ext}
)`
所以我运行setupcython.py build_ext --inplace 一旦完成,我得到了:
running build_ext
skipping 'clib.c' Cython extension (up-to-date)
building 'clib' extension
在我的文件夹
中创建了一个clib.c文件但是当我尝试在我的其他代码中导入clib时,它说
File "<ipython-input-27-aa10750d0f61>", line 1, in <module>
runfile('C:/Users/FAB/Desktop/code python/CPM-1celltype.py', wdir='C:/Users/FAB/Desktop/code python')
File "C:\ProgramData\Anaconda2\lib\site- packages\spyder\utils\site\sitecustomize.py", line 866, in runfile
execfile(filename, namespace)
File "C:\ProgramData\Anaconda2\lib\site-packages\spyder\utils\site\sitecustomize.py", line 87, in execfile
exec(compile(scripttext, filename, 'exec'), glob, loc)
File "C:/Users/FAB/Desktop/code python/CPM-1celltype.py", line 13, in <module>
import clib
ImportError: No module named clib
但是我确定我在正确的文件夹中,所以我不知道哪些是错的,你有什么想法吗?
谢谢