如何在pycharm python文件中导入已编译的cython文件?
这是我的设置。
在我的项目根目录中,cython类是" /classes/knn.cpython-35m-x86_64-linux-gnu.so"。 我的python文件是" /classes/testing_cython_knn.py"。
我在" / classes /"中有一个" __init __.py"文件...
但是,Pycharm无法将" .so"文件识别为可以导入的文件。 为了使该文件可导入,我需要做些什么,以便可以对其进行测试?
目前,我已经成功地在基于终端的常规python中编译并导入了" helloworld.so"文件...但是,我定义的函数是pythonic函数...没有C-stuff。
我的Cythonic文件是:
import numpy as np
cimport numpy as np
from scipy.stats import mode
from scipy.spatial.distance import cdist
from threading import Thread
cdef class KNN:
cdef public int k
cdef public str metric
cdef public np.ndarray trainingX
cdef public np.ndarray trainingY
cdef public np.ndarray predict(self,np.ndarray X):
cdef np.ndarray dis