zoukankan      html  css  js  c++  java
  • fatal error: Python.h: 没有那个文件或目录 解决方法

    今天安装scrapy

    先说下环境  Ubuntu16.04   系统默认Python 2.7.12 (default, Nov 19 2016, 06:48:10) ,安装过anaconda(很关键,里面有好多系统包,也是为什么此工具不十分依赖系统环境的原因,否则单独装matplotlib也是难弄!!!)
    在系统安装过程中,总是到twisted时报错,因为是源码安装的,所以系统要进行编译,但是找不到python.h文件!!!

    报错如下

    creating build/temp.linux-x86_64-2.7/src
    creating build/temp.linux-x86_64-2.7/src/twisted
    creating build/temp.linux-x86_64-2.7/src/twisted/test
    x86_64-linux-gnu-gcc -pthread -DNDEBUG -g -fwrapv -O2 -Wall -Wstrict-prototypes -fno-strict-aliasing -Wdate-time -D_FORTIFY_SOURCE=2 -g -fstack-protector-strong -Wformat -Werror=format-security -fPIC -I/usr/include/python2.7 -c src/twisted/test/raiser.c -o build/temp.linux-x86_64-2.7/src/twisted/test/raiser.o
    src/twisted/test/raiser.c:4:20: fatal error: Python.h: 没有那个文件或目录
    compilation terminated.
    error: command 'x86_64-linux-gnu-gcc' failed with exit status 1

    网上找了一下,没有能解决这个问题的

    有的是用安装 python-dev  但是系统安装不上,因为不满足依赖,主要是版本不一致,系统不允许安装的问题

    有人安装 sudo aptitude install python-dev
    但是也是无法安装成功的。
    我后来就find / -name Python.h 2>/dev/null   这个是看到别人的,也是这个启发了我。

    由于我安装过anaconda

    找到了这个文件,于是抱着试试看的态度

    sudo cp -R  /home/john/tools/anaconda2/pkgs/python-2.7.13-heccc3f1_16/include/python2.7/       /usr/include/

    为什么是/usr/include/位置, 何以在报错内容发现这个路径的!

    然后安装,我去竟然可以!!! 呵呵呵~~~~

    希望你也能成功!

  • 相关阅读:
    Vsftp的PASV mode(被动模式传送)和Port模式及 Linux下VsFTP配置全方案
    vsftpd:500 OOPS: vsftpd: refusing to run with writable root inside chroot ()错误的解决方法
    CentOS7.2部署FTP
    Apache与Nginx的优缺点比较
    MySQL存储引擎--MyISAM与InnoDB区别
    CentOS 7下搭建配置SVN服务器
    Remi 安装源
    tmpx75 I2C 温度传感器驱动程序添加
    QT 5.7.0 交叉编译记录
    am335x SGX 移植
  • 原文地址:https://www.cnblogs.com/if-then/p/7881887.html
Copyright © 2011-2022 走看看