zoukankan      html  css  js  c++  java
  • fatal error: Python.h: No such file or directory compilation terminated

    pip安装时报【fatal error: Python.h: No such file or directory compilation terminated】错误

     
    0.5722018.05.28 22:47:40字数 112阅读 13,589

    用pip安装第三方包的时候,有时候会遇到fatal error: Python.h: No such file or directory compilation terminated这样的报错。因为这些库使用了c扩展,需要编译,然后又找不到头文件和静态库导致的。编译这些c库需要的依赖库由python dev提供,安装即可:

    For apt (Ubuntu, Debian...):

    sudo apt-get install python-dev   # for python2.x installs
    sudo apt-get install python3-dev  # for python3.x installs
    

    For yum (CentOS, RHEL...):

    sudo yum install python-devel   # for python2.x installs
    sudo yum install python34-devel   # for python3.4 installs
    

    For dnf (Fedora...):

    sudo dnf install python2-devel  # for python2.x installs
    sudo dnf install python3-devel  # for python3.x installs
    

    For zypper (openSUSE...):

    sudo zypper in python-devel   # for python2.x installs
    sudo zypper in python3-devel  # for python3.x installs



    sudo pip install rpy2==2.8.5
    [sudo] password for gfk:
    DEPRECATION: Python 2.7 reached the end of its life on January 1st, 2020. Please upgrade your Python as Python 2.7 is no longer maintained. pip 21.0 will drop support for Python 2.7 in January 2021. More details about Python 2 support in pip can be found at https://pip.pypa.io/en/latest/development/release-process/#python-2-support pip 21.0 will remove support for this functionality.
    WARNING: The directory '/home/gfk/.cache/pip' or its parent directory is not owned or is not writable by the current user. The cache has been disabled. Check the permissions and owner of that directory. If executing pip with sudo, you may want sudo's -H flag.
    Collecting rpy2==2.8.5
    Downloading rpy2-2.8.5.tar.gz (184 kB)
    |████████████████████████████████| 184 kB 318 kB/s
    Requirement already satisfied: six in /home/gfk/.local/lib/python2.7/site-packages (from rpy2==2.8.5) (1.16.0)
    Requirement already satisfied: singledispatch in /usr/local/lib/python2.7/dist-packages (from rpy2==2.8.5) (3.6.2)
    Using legacy 'setup.py install' for rpy2, since package 'wheel' is not installed.
    Installing collected packages: rpy2
    Running setup.py install for rpy2 ... error
    ERROR: Command errored out with exit status 1:
    command: /usr/bin/python -u -c 'import sys, setuptools, tokenize; sys.argv[0] = '"'"'/tmp/pip-install-ZaXkTG/rpy2/setup.py'"'"'; __file__='"'"'/tmp/pip-install-ZaXkTG/rpy2/setup.py'"'"';f=getattr(tokenize, '"'"'open'"'"', open)(__file__);code=f.read().replace('"'"' '"'"', '"'"' '"'"');f.close();exec(compile(code, __file__, '"'"'exec'"'"'))' install --record /tmp/pip-record-F5IwRY/install-record.txt --single-version-externally-managed --compile --install-headers /usr/local/include/python2.7/rpy2
    cwd: /tmp/pip-install-ZaXkTG/rpy2/
    Complete output (139 lines):
    R version 4.1.0 (2021-05-18) -- "Camp Pontanezen"
    /usr/lib/R/bin/R CMD config --ldflags
    /usr/lib/R/bin/R CMD config --cppflags

    Compilation parameters for rpy2's C components:
    include_dirs = ['/usr/share/R/include']
    library_dirs = ['/usr/lib/R/lib']
    libraries = ['R', 'pcre2-8', 'lzma', 'bz2', 'z', 'rt', 'dl', 'm']
    extra_link_args = ['-Wl,--export-dynamic', '-fopenmp', '-Wl,-Bsymbolic-functions', '-Wl,-z,relro']

    running install
    running build
    running build_py
    creating build
    creating build/lib.linux-x86_64-2.7
    creating build/lib.linux-x86_64-2.7/rpy2
    copying ./rpy/__init__.py -> build/lib.linux-x86_64-2.7/rpy2
    copying ./rpy/rpy_classic.py -> build/lib.linux-x86_64-2.7/rpy2
    copying ./rpy/tests.py -> build/lib.linux-x86_64-2.7/rpy2
    copying ./rpy/tests_rpy_classic.py -> build/lib.linux-x86_64-2.7/rpy2
    creating build/lib.linux-x86_64-2.7/rpy2/rlike
    copying ./rpy/rlike/container.py -> build/lib.linux-x86_64-2.7/rpy2/rlike
    copying ./rpy/rlike/indexing.py -> build/lib.linux-x86_64-2.7/rpy2/rlike
    copying ./rpy/rlike/__init__.py -> build/lib.linux-x86_64-2.7/rpy2/rlike
    copying ./rpy/rlike/functional.py -> build/lib.linux-x86_64-2.7/rpy2/rlike
    creating build/lib.linux-x86_64-2.7/rpy2/rlike/tests
    copying ./rpy/rlike/tests/test_functional.py -> build/lib.linux-x86_64-2.7/rpy2/rlike/tests
    copying ./rpy/rlike/tests/test_indexing.py -> build/lib.linux-x86_64-2.7/rpy2/rlike/tests
    copying ./rpy/rlike/tests/__init__.py -> build/lib.linux-x86_64-2.7/rpy2/rlike/tests
    copying ./rpy/rlike/tests/test_container.py -> build/lib.linux-x86_64-2.7/rpy2/rlike/tests
    creating build/lib.linux-x86_64-2.7/rpy2/rinterface
    copying ./rpy/rinterface/__init__.py -> build/lib.linux-x86_64-2.7/rpy2/rinterface
    creating build/lib.linux-x86_64-2.7/rpy2/rinterface/tests
    copying ./rpy/rinterface/tests/test_Device.py -> build/lib.linux-x86_64-2.7/rpy2/rinterface/tests
    copying ./rpy/rinterface/tests/test_SexpEnvironment.py -> build/lib.linux-x86_64-2.7/rpy2/rinterface/tests
    copying ./rpy/rinterface/tests/__init__.py -> build/lib.linux-x86_64-2.7/rpy2/rinterface/tests
    copying ./rpy/rinterface/tests/test_Sexp.py -> build/lib.linux-x86_64-2.7/rpy2/rinterface/tests
    copying ./rpy/rinterface/tests/test_SexpExtPtr.py -> build/lib.linux-x86_64-2.7/rpy2/rinterface/tests
    copying ./rpy/rinterface/tests/test_SexpClosure.py -> build/lib.linux-x86_64-2.7/rpy2/rinterface/tests
    copying ./rpy/rinterface/tests/test_SexpVector.py -> build/lib.linux-x86_64-2.7/rpy2/rinterface/tests
    copying ./rpy/rinterface/tests/test_SexpVectorNumeric.py -> build/lib.linux-x86_64-2.7/rpy2/rinterface/tests
    copying ./rpy/rinterface/tests/test_SexpSymbol.py -> build/lib.linux-x86_64-2.7/rpy2/rinterface/tests
    copying ./rpy/rinterface/tests/test_EmbeddedR.py -> build/lib.linux-x86_64-2.7/rpy2/rinterface/tests
    creating build/lib.linux-x86_64-2.7/rpy2/robjects
    copying ./rpy/robjects/functions.py -> build/lib.linux-x86_64-2.7/rpy2/robjects
    copying ./rpy/robjects/robject.py -> build/lib.linux-x86_64-2.7/rpy2/robjects
    copying ./rpy/robjects/language.py -> build/lib.linux-x86_64-2.7/rpy2/robjects
    copying ./rpy/robjects/numpy2ri.py -> build/lib.linux-x86_64-2.7/rpy2/robjects
    copying ./rpy/robjects/packages.py -> build/lib.linux-x86_64-2.7/rpy2/robjects
    copying ./rpy/robjects/environments.py -> build/lib.linux-x86_64-2.7/rpy2/robjects
    copying ./rpy/robjects/__init__.py -> build/lib.linux-x86_64-2.7/rpy2/robjects
    copying ./rpy/robjects/vectors.py -> build/lib.linux-x86_64-2.7/rpy2/robjects
    copying ./rpy/robjects/help.py -> build/lib.linux-x86_64-2.7/rpy2/robjects
    copying ./rpy/robjects/constants.py -> build/lib.linux-x86_64-2.7/rpy2/robjects
    copying ./rpy/robjects/conversion.py -> build/lib.linux-x86_64-2.7/rpy2/robjects
    copying ./rpy/robjects/packages_utils.py -> build/lib.linux-x86_64-2.7/rpy2/robjects
    copying ./rpy/robjects/pandas2ri.py -> build/lib.linux-x86_64-2.7/rpy2/robjects
    copying ./rpy/robjects/methods.py -> build/lib.linux-x86_64-2.7/rpy2/robjects
    creating build/lib.linux-x86_64-2.7/rpy2/robjects/tests
    copying ./rpy/robjects/tests/testRobjects.py -> build/lib.linux-x86_64-2.7/rpy2/robjects/tests
    copying ./rpy/robjects/tests/testEnvironment.py -> build/lib.linux-x86_64-2.7/rpy2/robjects/tests
    copying ./rpy/robjects/tests/testPackages.py -> build/lib.linux-x86_64-2.7/rpy2/robjects/tests
    copying ./rpy/robjects/tests/testHelp.py -> build/lib.linux-x86_64-2.7/rpy2/robjects/tests
    copying ./rpy/robjects/tests/testPandasConversions.py -> build/lib.linux-x86_64-2.7/rpy2/robjects/tests
    copying ./rpy/robjects/tests/testFormula.py -> build/lib.linux-x86_64-2.7/rpy2/robjects/tests
    copying ./rpy/robjects/tests/testVector.py -> build/lib.linux-x86_64-2.7/rpy2/robjects/tests
    copying ./rpy/robjects/tests/testLanguage.py -> build/lib.linux-x86_64-2.7/rpy2/robjects/tests
    copying ./rpy/robjects/tests/__init__.py -> build/lib.linux-x86_64-2.7/rpy2/robjects/tests
    copying ./rpy/robjects/tests/testArray.py -> build/lib.linux-x86_64-2.7/rpy2/robjects/tests
    copying ./rpy/robjects/tests/testRObject.py -> build/lib.linux-x86_64-2.7/rpy2/robjects/tests
    copying ./rpy/robjects/tests/testFunction.py -> build/lib.linux-x86_64-2.7/rpy2/robjects/tests
    copying ./rpy/robjects/tests/testDataFrame.py -> build/lib.linux-x86_64-2.7/rpy2/robjects/tests
    copying ./rpy/robjects/tests/testNumpyConversions.py -> build/lib.linux-x86_64-2.7/rpy2/robjects/tests
    copying ./rpy/robjects/tests/testMethods.py -> build/lib.linux-x86_64-2.7/rpy2/robjects/tests
    creating build/lib.linux-x86_64-2.7/rpy2/robjects/lib
    copying ./rpy/robjects/lib/grid.py -> build/lib.linux-x86_64-2.7/rpy2/robjects/lib
    copying ./rpy/robjects/lib/ggplot2.py -> build/lib.linux-x86_64-2.7/rpy2/robjects/lib
    copying ./rpy/robjects/lib/__init__.py -> build/lib.linux-x86_64-2.7/rpy2/robjects/lib
    copying ./rpy/robjects/lib/tidyr.py -> build/lib.linux-x86_64-2.7/rpy2/robjects/lib
    copying ./rpy/robjects/lib/grdevices.py -> build/lib.linux-x86_64-2.7/rpy2/robjects/lib
    copying ./rpy/robjects/lib/dplyr.py -> build/lib.linux-x86_64-2.7/rpy2/robjects/lib
    creating build/lib.linux-x86_64-2.7/rpy2/robjects/lib/tests
    copying ./rpy/robjects/lib/tests/test_grdevices.py -> build/lib.linux-x86_64-2.7/rpy2/robjects/lib/tests
    copying ./rpy/robjects/lib/tests/test_dplyr.py -> build/lib.linux-x86_64-2.7/rpy2/robjects/lib/tests
    copying ./rpy/robjects/lib/tests/test_ggplot2.py -> build/lib.linux-x86_64-2.7/rpy2/robjects/lib/tests
    copying ./rpy/robjects/lib/tests/__init__.py -> build/lib.linux-x86_64-2.7/rpy2/robjects/lib/tests
    creating build/lib.linux-x86_64-2.7/rpy2/interactive
    copying ./rpy/interactive/packages.py -> build/lib.linux-x86_64-2.7/rpy2/interactive
    copying ./rpy/interactive/__init__.py -> build/lib.linux-x86_64-2.7/rpy2/interactive
    copying ./rpy/interactive/process_revents.py -> build/lib.linux-x86_64-2.7/rpy2/interactive
    creating build/lib.linux-x86_64-2.7/rpy2/interactive/tests
    copying ./rpy/interactive/tests/__init__.py -> build/lib.linux-x86_64-2.7/rpy2/interactive/tests
    creating build/lib.linux-x86_64-2.7/rpy2/ipython
    copying ./rpy/ipython/ggplot.py -> build/lib.linux-x86_64-2.7/rpy2/ipython
    copying ./rpy/ipython/html.py -> build/lib.linux-x86_64-2.7/rpy2/ipython
    copying ./rpy/ipython/__init__.py -> build/lib.linux-x86_64-2.7/rpy2/ipython
    copying ./rpy/ipython/rmagic.py -> build/lib.linux-x86_64-2.7/rpy2/ipython
    creating build/lib.linux-x86_64-2.7/rpy2/ipython/tests
    copying ./rpy/ipython/tests/__init__.py -> build/lib.linux-x86_64-2.7/rpy2/ipython/tests
    copying ./rpy/ipython/tests/test_rmagic.py -> build/lib.linux-x86_64-2.7/rpy2/ipython/tests
    running build_clib
    building 'r_utils' library
    creating build/temp.linux-x86_64-2.7
    creating build/temp.linux-x86_64-2.7/rpy
    creating build/temp.linux-x86_64-2.7/rpy/rinterface
    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./rpy/rinterface -I/usr/share/R/include -c ./rpy/rinterface/r_utils.c -o build/temp.linux-x86_64-2.7/./rpy/rinterface/r_utils.o
    In file included from /usr/share/R/include/Rdefines.h:36:0,
    from ./rpy/rinterface/r_utils.c:23:
    /usr/share/R/include/R_ext/Memory.h:48:1: warning: function declaration isn’t a prototype [-Wstrict-prototypes]
    int R_gc_running();
    ^
    In file included from /usr/share/R/include/Rinternals.h:51:0,
    from /usr/share/R/include/Rdefines.h:40,
    from ./rpy/rinterface/r_utils.c:23:
    /usr/share/R/include/R_ext/Rdynload.h:38:1: warning: function declaration isn’t a prototype [-Wstrict-prototypes]
    typedef void * (*DL_FUNC)();
    ^
    In file included from /usr/share/R/include/Rdefines.h:40:0,
    from ./rpy/rinterface/r_utils.c:23:
    /usr/share/R/include/Rinternals.h:1228:1: warning: function declaration isn’t a prototype [-Wstrict-prototypes]
    SEXP R_GetCurrentEnv();
    ^
    /usr/share/R/include/Rinternals.h:1229:1: warning: function declaration isn’t a prototype [-Wstrict-prototypes]
    const char *R_curErrorBuf();
    ^
    /usr/share/R/include/Rinternals.h:1306:1: warning: function declaration isn’t a prototype [-Wstrict-prototypes]
    void R_init_altrep();
    ^
    /usr/share/R/include/Rinternals.h:1321:1: warning: function declaration isn’t a prototype [-Wstrict-prototypes]
    SEXP R_MakeUnwindCont();
    ^
    x86_64-linux-gnu-gcc-ar rc build/temp.linux-x86_64-2.7/libr_utils.a build/temp.linux-x86_64-2.7/./rpy/rinterface/r_utils.o
    running build_ext
    R version 4.1.0 (2021-05-18) -- "Camp Pontanezen"
    building 'rpy2.rinterface._rinterface' extension
    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 -DR_INTERFACE_PTRS=1 -DHAVE_POSIX_SIGJMP=1 -DRIF_HAS_RSIGHAND=1 -DCSTACK_DEFNS=1 -DHAS_READLINE=1 -I./rpy/rinterface -I/usr/share/R/include -I/usr/include/python2.7 -c ./rpy/rinterface/_rinterface.c -o build/temp.linux-x86_64-2.7/./rpy/rinterface/_rinterface.o
    ./rpy/rinterface/_rinterface.c:49:20: fatal error: Python.h: No such file or directory
    compilation terminated.
    error: command 'x86_64-linux-gnu-gcc' failed with exit status 1
    ----------------------------------------
    ERROR: Command errored out with exit status 1: /usr/bin/python -u -c 'import sys, setuptools, tokenize; sys.argv[0] = '"'"'/tmp/pip-install-ZaXkTG/rpy2/setup.py'"'"'; __file__='"'"'/tmp/pip-install-ZaXkTG/rpy2/setup.py'"'"';f=getattr(tokenize, '"'"'open'"'"', open)(__file__);code=f.read().replace('"'"' '"'"', '"'"' '"'"');f.close();exec(compile(code, __file__, '"'"'exec'"'"'))' install --record /tmp/pip-record-F5IwRY/install-record.txt --single-version-externally-managed --compile --install-headers /usr/local/include/python2.7/rpy2 Check the logs for full command output.

     
  • 相关阅读:
    js通过class获取元素时的兼容性解决方案
    html5的八大特性
    typeof与instanceof的区别
    evel()与JSON.parset()的区别
    apt-get出现的问题
    Linux下开启计划任务日志
    ls
    win10自带IE上不了网的解决办法
    crontab -e文件存放路径
    Linux系统下面crontab选择默认编译器
  • 原文地址:https://www.cnblogs.com/xiaojikuaipao/p/14982627.html
Copyright © 2011-2022 走看看