使用pycocotools时出现"undefined symbol: _Py_ZeroStruct"

问题描述:

运行

from pycocotools.coco import COCO

报错:

ImportError: /home/elijha/PycharmProjects/LinkinNet/cocoapi-master/PythonAPI/pycocotools/_mask.so: undefined symbol: _Py_ZeroStruct

出错原因

stackoverflow的回答

This error message is typical when there’s a version mismatch in Python modules. It could something like cython_bbox.so was compiled and linked against Python 2.7 and CNTK was compiled against Python 3.5. It’s hard to say exactly what the reason is but you can try to do make inside a python environment that matches your CNTK version and see if that works.

检查后发现,我把Cython安装在了python2.7的环境内,而且make也是在此环境下进行的。而import的环境是python3.5,因此出错。

解决方法

  1. 在python2.7下卸载Cython。(这一步其实可以不做,但是因为我从来不用这个环境,就也卸载了。)
  2. 进入python3.5,执行pip install Cython
  3. 重进进入pycocotools文件夹,执行make。(即用python3重新运行pycocotools下的setup.py进行安装。)
  4. 重新运行from pycocotools.coco import COCO,正确。
  • 2
    点赞
  • 3
    收藏
    觉得还不错? 一键收藏
  • 4
    评论
评论 4
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值