我有这两行代码:
from libc.stdlib cimport malloc, calloc, realloc, free
from optv.tracking_framebuf cimport TargetArray
PyCharm(2016.2.3专业版在Ubuntu 14.04上)没有突出显示第一个作为未解决的参考,但第二行以红色突出显示为未解析的参考.
我的TargetArray类位于tracking_framebuf.pxd文件中,该文件位于/usr/local/lib/python2.7/dist-packages/optv/以及同名的.c,.pyx,.so文件中.
我插入/usr/local/lib/python2.7/dist-packages/optv/和/usr/local/lib/python2.7/dist-packages/路径与python解释器关联,但错误消息仍然是apearing在编辑器中.
尽管有错误消息,但使用此setup.py脚本成功进行了cython化(以及其他文件):
# -*- coding: utf-8 -*-
from distutils.core import setup
from Cython.Distutils import build_ext
from Cython.Distutils.extension import Extension
import numpy as np
import os
inc_dirs = [np.get_include(), '.']
def mk_ext(name, files):
return Extension(name, files, libraries=['optv'], include_dirs=inc_dirs,
pyrex_include_dirs=['.'])
ext_mods = [
mk_ext("optv.tracking_framebuf", ["optv/tracking_framebuf.pyx"]),
mk_ext("optv.parameters", ["optv/parameters.pyx"]),
mk_ext("optv.calibration", ["optv/calibration.pyx"]),
mk_ext("optv.transforms", ["optv/transforms.pyx"]),
mk_ext("optv.imgcoord", ["optv/imgcoord.pyx"]),
mk_ext("optv.image_processing", ["optv/image_processing.pyx"]),
mk_ext("optv.segmentation", ["optv/segmentation.pyx"]),
mk_ext("optv.orientation", ["optv/orientation.pyx"])
]
setup(
name="optv",
cmdclass = {'build_ext': build_ext},
packages=['optv'],
ext_modules = ext_mods,
package_data = {'optv': ['*.pxd']}
)
我是否遗漏了一些东西,以摆脱这些错误消息,并能够查看我放在路径中的.pxd文件的内容?