1.剛開始不會用才導致.
2.首先瞭解一下基本知識。要寫 either make a setup.py for the module, as described at this page, or use pyximport to automatically compile and build your module with just an import.我選第一個。
set.py如下詳解解釋參考
#!/usr/bin/env python# import osfrom setuptools import find_packagesfrom distutils.core import setupfrom distutils.extension import Extensionfrom Cython.Build import cythonizedef read(fname): return open(os.path.join(os.path.dirname(__file__), fname)).read()ext_modules = []ext_modules += [ Extension("lrec.evaluate.cy_ranking_metric", [ "lrec/evaluate/cy_ranking_metric.pyx"]), Extension("lrec.utils.data_utils.data_cython_helpers", [ "lrec/utils/data_utils/data_cython_helpers.pyx"]),]setup( name="LRec", version="0.1", author="Zhougongyu", packages=find_packages(), include_package_data=True, zip_safe=False, package_dir={'': '.'}, ext_modules=cythonize(ext_modules),).3.使用命令pyx檔案產生build檔案找到c和pdy檔案
python setup.py install
4.把這三個放在一個檔案夾下如圖:
5.成功運行