Max*_*gal 5 python cython pycharm
我有这两行代码:
from libc.stdlib cimport malloc, calloc, realloc, free
from optv.tracking_framebuf cimport TargetArray
Run Code Online (Sandbox Code Playgroud)
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']}
)
Run Code Online (Sandbox Code Playgroud)
我是否遗漏了一些东西,以摆脱这些错误消息,并能够查看我放在路径中的.pxd文件的内容?
通过以下方式添加/usr/local/lib/python2.7/dist-packages/PYTHONPATH 解决了这个问题:
文件 - >设置 - >项目 - >项目结构 - >添加内容根.