ubuntu 16.04 pycocotools 踩坑记录

1. GCC & G++ 问题,报错如下:

  fatal error: math.h: No such file or directory
  fatal error: limits.h: No such file or directory
  • 解决方法:
    1. 修改 /etc/sources.list 内容为 ustc 软件镜像源
    2. 然后 sudo apt get update 更新索引之后重装GCC
    3. sudo apt-get remove gcc 卸载 GCC
    4. sudo apt-get install build-essential 重装
    5. 查看 gcc & g++ 是否安装成功
      xxxxxxxxxxx# gcc --version
      gcc (Ubuntu 5.4.0-6ubuntu1~16.04.12) 5.4.0 20160609
      Copyright (C) 2015 Free Software Foundation, Inc.
      This is free software; see the source for copying conditions.  
      There is NO warranty; 
      not even for MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.
      

2. 报错如下

pycocotools/_mask.c:14254:21: error: ‘PyThreadState {aka struct _ts}’ has no member named ‘exc_type’; did you mean ‘curexc_type’?
     *type = tstate->exc_type;
                     ^~~~~~~~
                     curexc_type
pycocotools/_mask.c:14255:22: error: ‘PyThreadState {aka struct _ts}’ has no member named ‘exc_value’; did you mean ‘curexc_value’?
     *value = tstate->exc_value;
                      ^~~~~~~~~
                      curexc_value
pycocotools/_mask.c:14256:19: error: ‘PyThreadState {aka struct _ts}’ has no member named ‘exc_traceback’; did you mean ‘curexc_traceback’?
     *tb = tstate->exc_traceback;
                   ^~~~~~~~~~~~~
                   curexc_traceback
pycocotools/_mask.c: In function ‘__Pyx__ExceptionReset’:
pycocotools/_mask.c:14263:24: error: ‘PyThreadState {aka struct _ts}’ has no member named ‘exc_type’; did you mean ‘curexc_type’?
     tmp_type = tstate->exc_type;
                ^~~~~~~~
                 curexc_type
pycocotools/_mask.c:14264:25: error: ‘PyThreadState {aka struct _ts}’ has no member named ‘exc_value’; did you mean ‘curexc_value’?
     tmp_value = tstate->exc_value;
                         ^~~~~~~~~
                         curexc_value
pycocotools/_mask.c:14265:22: error: ‘PyThreadState {aka struct _ts}’ has no member named ‘exc_traceback’; did you mean ‘curexc_traceback’?
     tmp_tb = tstate->exc_traceback;
                      ^~~~~~~~~~~~~
                      curexc_traceback
pycocotools/_mask.c:14266:13: error: ‘PyThreadState {aka struct _ts}’ has no member named ‘exc_type’; did you mean ‘curexc_type’?
     tstate->exc_type = type;
             ^~~~~~~~
             curexc_type
pycocotools/_mask.c:14267:13: error: ‘PyThreadState {aka struct _ts}’ has no member named ‘exc_value’; did you mean ‘curexc_value’?
     tstate->exc_value = value;
             ^~~~~~~~~
             curexc_value
pycocotools/_mask.c:14268:13: error: ‘PyThreadState {aka struct _ts}’ has no member named ‘exc_traceback’; did you mean ‘curexc_traceback’?
     tstate->exc_traceback = tb;
             ^~~~~~~~~~~~~
             curexc_traceback
pycocotools/_mask.c: In function ‘__Pyx__GetException’:
pycocotools/_mask.c:14323:24: error: ‘PyThreadState {aka struct _ts}’ has no member named ‘exc_type’; did you mean ‘curexc_type’?
     tmp_type = tstate->exc_type;
                        ^~~~~~~~
                        curexc_type
pycocotools/_mask.c:14324:25: error: ‘PyThreadState {aka struct _ts}’ has no member named ‘exc_value’; did you mean ‘curexc_value’?
     tmp_value = tstate->exc_value;
                         ^~~~~~~~~
                         curexc_value
pycocotools/_mask.c:14325:22: error: ‘PyThreadState {aka struct _ts}’ has no member named ‘exc_traceback’; did you mean ‘curexc_traceback’?
     tmp_tb = tstate->exc_traceback;
                      ^~~~~~~~~~~~~
                      curexc_traceback
pycocotools/_mask.c:14326:13: error: ‘PyThreadState {aka struct _ts}’ has no member named ‘exc_type’; did you mean ‘curexc_type’?
     tstate->exc_type = local_type;
             ^~~~~~~~
             curexc_type
pycocotools/_mask.c:14327:13: error: ‘PyThreadState {aka struct _ts}’ has no member named ‘exc_value’; did you mean ‘curexc_value’?
     tstate->exc_value = local_value;
             ^~~~~~~~~
             curexc_value
pycocotools/_mask.c:14328:13: error: ‘PyThreadState {aka struct _ts}’ has no member named ‘exc_traceback’; did you mean ‘curexc_traceback’?
     tstate->exc_traceback = local_tb;
             ^~~~~~~~~~~~~
             curexc_traceback
error: command 'gcc' failed with exit status 1
  • 解决办法(来源:走的那么干脆的博客):删除pycocotools文件夹(对应第二张图)下的pycache文件夹、_init.py文件、_mask.c文件以及_mask.cpython-36m-x86_64-linux-gnu.so文件。

3. 依赖的安装

checkdep_freetype2.c:3:6: error: #error "FreeType version 2.3 or higher is required. You may set the MPLLOCALFREETYPE environment variable to 1 to let Matplotlib download it."

或者

Searching for scikit-learn
Reading https://pypi.python.org/simple/scikit-learn/
Downloading https://files.pythonhosted.org/packages/72/e4/75247cf75e9e3ba1bf296c9d26ba1cfc71d781821d32bcdb4d9b4b1b4153/scikit-learn-0.23.0.tar.gz#sha256=639a53df6273acc6a7510fb0c658b94e0c70bb13dafff9d14932c981ff9baff4
Best match: scikit-learn 0.23.0
Processing scikit-learn-0.23.0.tar.gz
Writing /tmp/easy_install-_oy3y34m/scikit-learn-0.23.0/setup.cfg
Running scikit-learn-0.23.0/setup.py -q bdist_egg --dist-dir /tmp/easy_install-_oy3y34m/scikit-learn-0.23.0/egg-dist-tmp-frtmbvbp
Partial import of sklearn during the build process.
Traceback (most recent call last):
  File "/home/fanglin/.conda/envs/action/lib/python3.6/site-packages/setuptools/sandbox.py", line 158, in save_modules
    yield saved
  File "/home/fanglin/.conda/envs/action/lib/python3.6/site-packages/setuptools/sandbox.py", line 199, in setup_context
    yield
  File "/home/fanglin/.conda/envs/action/lib/python3.6/site-packages/setuptools/sandbox.py", line 254, in run_setup
    _execfile(setup_script, ns)
  File "/home/fanglin/.conda/envs/action/lib/python3.6/site-packages/setuptools/sandbox.py", line 49, in _execfile
    exec(code, globals, locals)
  File "/tmp/easy_install-_oy3y34m/scikit-learn-0.23.0/setup.py", line 124, in <module>
  File "/home/fanglin/.conda/envs/action/lib/python3.6/site-packages/numpy/__init__.py", line 142, in <module>
    from . import core
  File "/home/fanglin/.conda/envs/action/lib/python3.6/site-packages/numpy/core/__init__.py", line 24, in <module>
    from . import multiarray
  File "/home/fanglin/.conda/envs/action/lib/python3.6/site-packages/numpy/core/multiarray.py", line 14, in <module>
    from . import overrides
  File "/home/fanglin/.conda/envs/action/lib/python3.6/site-packages/numpy/core/overrides.py", line 47, in <module>
    """)
RuntimeError: implement_array_function method already has a docstring

或者

Searching for python-dateutil>=2.1
Reading https://pypi.python.org/simple/python-dateutil/
Downloading https://files.pythonhosted.org/packages/be/ed/5bbc91f03fa4c839c4c7360375da77f9659af5f7086b7a7bdda65771c8e0/python-dateutil-2.8.1.tar.gz#sha256=73ebfe9dbf22e832286dafa60473e4cd239f8592f699aa5adaf10050e6e1823c
Best match: python-dateutil 2.8.1
Processing python-dateutil-2.8.1.tar.gz
Writing /tmp/easy_install-vap9bp6t/python-dateutil-2.8.1/setup.cfg
Running python-dateutil-2.8.1/setup.py -q bdist_egg --dist-dir /tmp/easy_install-vap9bp6t/python-dateutil-2.8.1/egg-dist-tmp-g_wojrcb
/usr/share/anaconda3/envs/action/lib/python3.6/distutils/dist.py:261: UserWarning: Unknown distribution option: 'use_scm_version'
  warnings.warn(msg)
warning: no previously-included files matching '__pycache__' found anywhere in distribution
warning: no previously-included files matching '*.py[co]' found anywhere in distribution
Moving python_dateutil-0.0.0-py3.6.egg to /usr/share/anaconda3/envs/action/lib/python3.6/site-packages
Adding python-dateutil 0.0.0 to easy-install.pth file

Installed /usr/share/anaconda3/envs/action/lib/python3.6/site-packages/python_dateutil-0.0.0-py3.6.egg
error: The 'python-dateutil>=2.1' distribution was not found and is required by matplotlib
  • 解决方法:类似报错,都也可以通过手动安装依赖包 pip install package# 来解决,package# 达标报错中出现的依赖包名称。
最后编辑于
©著作权归作者所有,转载或内容合作请联系作者
  • 序言:七十年代末,一起剥皮案震惊了整个滨河市,随后出现的几起案子,更是在滨河造成了极大的恐慌,老刑警刘岩,带你破解...
    沈念sama阅读 203,456评论 5 477
  • 序言:滨河连续发生了三起死亡事件,死亡现场离奇诡异,居然都是意外死亡,警方通过查阅死者的电脑和手机,发现死者居然都...
    沈念sama阅读 85,370评论 2 381
  • 文/潘晓璐 我一进店门,熙熙楼的掌柜王于贵愁眉苦脸地迎上来,“玉大人,你说我怎么就摊上这事。” “怎么了?”我有些...
    开封第一讲书人阅读 150,337评论 0 337
  • 文/不坏的土叔 我叫张陵,是天一观的道长。 经常有香客问我,道长,这世上最难降的妖魔是什么? 我笑而不...
    开封第一讲书人阅读 54,583评论 1 273
  • 正文 为了忘掉前任,我火速办了婚礼,结果婚礼上,老公的妹妹穿的比我还像新娘。我一直安慰自己,他们只是感情好,可当我...
    茶点故事阅读 63,596评论 5 365
  • 文/花漫 我一把揭开白布。 她就那样静静地躺着,像睡着了一般。 火红的嫁衣衬着肌肤如雪。 梳的纹丝不乱的头发上,一...
    开封第一讲书人阅读 48,572评论 1 281
  • 那天,我揣着相机与录音,去河边找鬼。 笑死,一个胖子当着我的面吹牛,可吹牛的内容都是我干的。 我是一名探鬼主播,决...
    沈念sama阅读 37,936评论 3 395
  • 文/苍兰香墨 我猛地睁开眼,长吁一口气:“原来是场噩梦啊……” “哼!你这毒妇竟也来了?” 一声冷哼从身侧响起,我...
    开封第一讲书人阅读 36,595评论 0 258
  • 序言:老挝万荣一对情侣失踪,失踪者是张志新(化名)和其女友刘颖,没想到半个月后,有当地人在树林里发现了一具尸体,经...
    沈念sama阅读 40,850评论 1 297
  • 正文 独居荒郊野岭守林人离奇死亡,尸身上长有42处带血的脓包…… 初始之章·张勋 以下内容为张勋视角 年9月15日...
    茶点故事阅读 35,601评论 2 321
  • 正文 我和宋清朗相恋三年,在试婚纱的时候发现自己被绿了。 大学时的朋友给我发了我未婚夫和他白月光在一起吃饭的照片。...
    茶点故事阅读 37,685评论 1 329
  • 序言:一个原本活蹦乱跳的男人离奇死亡,死状恐怖,灵堂内的尸体忽然破棺而出,到底是诈尸还是另有隐情,我是刑警宁泽,带...
    沈念sama阅读 33,371评论 4 318
  • 正文 年R本政府宣布,位于F岛的核电站,受9级特大地震影响,放射性物质发生泄漏。R本人自食恶果不足惜,却给世界环境...
    茶点故事阅读 38,951评论 3 307
  • 文/蒙蒙 一、第九天 我趴在偏房一处隐蔽的房顶上张望。 院中可真热闹,春花似锦、人声如沸。这庄子的主人今日做“春日...
    开封第一讲书人阅读 29,934评论 0 19
  • 文/苍兰香墨 我抬头看了看天上的太阳。三九已至,却和暖如春,着一层夹袄步出监牢的瞬间,已是汗流浃背。 一阵脚步声响...
    开封第一讲书人阅读 31,167评论 1 259
  • 我被黑心中介骗来泰国打工, 没想到刚下飞机就差点儿被人妖公主榨干…… 1. 我叫王不留,地道东北人。 一个月前我还...
    沈念sama阅读 43,636评论 2 349
  • 正文 我出身青楼,却偏偏与公主长得像,于是被迫代替她去往敌国和亲。 传闻我的和亲对象是个残疾皇子,可洞房花烛夜当晚...
    茶点故事阅读 42,411评论 2 342