error: readline/readline.h: No such file or directory

报如下错:

[root@localhost rpy2-2.8.5]# python setup.py install
R version 3.3.2 (2016-10-31) -- "Sincere Pumpkin Patch"
/usr/lib64/R/bin/R CMD config --ldflags
/usr/lib64/R/bin/R CMD config --cppflags

    Compilation parameters for rpy2's C components:
        include_dirs    = ['/usr/include/R']
        library_dirs    = ['/usr/lib64/R/lib']
        libraries       = ['R', 'pcre', 'lzma', 'bz2', 'z', 'rt', 'dl', 'm', 'icuuc', 'icui18n']
        extra_link_args = ['-Wl,--export-dynamic', '-fopenmp']
    
running install
running bdist_egg
running egg_info
writing requirements to rpy2.egg-info/requires.txt
writing rpy2.egg-info/PKG-INFO
writing top-level names to rpy2.egg-info/top_level.txt
writing dependency_links to rpy2.egg-info/dependency_links.txt
R version 3.3.2 (2016-10-31) -- "Sincere Pumpkin Patch"
reading manifest file 'rpy2.egg-info/SOURCES.txt'
reading manifest template 'MANIFEST.in'
warning: no previously-included files matching '*patch*' found anywhere in distribution
warning: no previously-included files matching '*diff*' found anywhere in distribution
warning: no previously-included files matching '.hg' found anywhere in distribution
warning: no files found matching 'MANIFEST'
warning: no files found matching 'README'
warning: no files found matching 'MPL_LICENSE'
warning: no files found matching 'GPL_LICENSE'
warning: no files found matching 'LGPL_LICENSE'
no previously-included directories found matching 'dist'
warning: no files found matching 'doc/source/rpy2_logo.png'
writing manifest file 'rpy2.egg-info/SOURCES.txt'
installing library code to build/bdist.linux-x86_64/egg
running build_clib
building 'r_utils' library
gcc -pthread -fno-strict-aliasing -g -O2 -DNDEBUG -g -fwrapv -O3 -Wall -Wstrict-prototypes -fPIC -I./rpy/rinterface -I/usr/include/R -c ./rpy/rinterface/r_utils.c -o build/temp.linux-x86_64-2.7/./rpy/rinterface/r_utils.o
In file included from /usr/include/R/Rdefines.h:32,
                 from ./rpy/rinterface/r_utils.c:23:
/usr/include/R/R_ext/Memory.h:47: warning: function declaration isn’t a prototype
In file included from /usr/include/R/Rdefines.h:36,
                 from ./rpy/rinterface/r_utils.c:23:
/usr/include/R/Rinternals.h:882: warning: function declaration isn’t a prototype
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 install_lib
running build_py
running build_ext
building 'rpy2.rinterface._rinterface' extension
gcc -pthread -fno-strict-aliasing -g -O2 -DNDEBUG -g -fwrapv -O3 -Wall -Wstrict-prototypes -fPIC -DR_INTERFACE_PTRS=1 -DHAVE_POSIX_SIGJMP=1 -DRIF_HAS_RSIGHAND=1 -DCSTACK_DEFNS=1 -DHAS_READLINE=1 -I./rpy/rinterface -I/usr/include/R -I/usr/local/python27/include/python2.7 -c ./rpy/rinterface/_rinterface.c -o build/temp.linux-x86_64-2.7/./rpy/rinterface/_rinterface.o
In file included from /usr/local/python27/include/python2.7/Python.h:8,
                 from ./rpy/rinterface/_rinterface.c:49:
/usr/local/python27/include/python2.7/pyconfig.h:1190:1: warning: "_POSIX_C_SOURCE" redefined
In file included from /usr/include/signal.h:29,
                 from ./rpy/rinterface/_rinterface.c:45:
/usr/include/features.h:213:1: warning: this is the location of the previous definition
In file included from /usr/include/R/R.h:76,
                 from ./rpy/rinterface/_rinterface.h:8,
                 from ./rpy/rinterface/_rinterface.c:52:
/usr/include/R/R_ext/Memory.h:47: warning: function declaration isn’t a prototype
In file included from ./rpy/rinterface/_rinterface.h:9,
                 from ./rpy/rinterface/_rinterface.c:52:
/usr/include/R/Rinternals.h:882: warning: function declaration isn’t a prototype
In file included from ./rpy/rinterface/_rinterface.c:64:
/usr/include/R/Rinterface.h:146: warning: function declaration isn’t a prototype
In file included from ./rpy/rinterface/_rinterface.c:73:
/usr/include/R/R_ext/Rdynload.h:32: warning: function declaration isn’t a prototype
./rpy/rinterface/_rinterface.c:80:31: error: readline/readline.h: No such file or directory
In file included from ./rpy/rinterface/_rinterface.c:116:
./rpy/rinterface/embeddedr.c: In function ‘SexpObject_clear’:
./rpy/rinterface/embeddedr.c:48: warning: unused variable ‘res’
In file included from ./rpy/rinterface/_rinterface.c:119:
./rpy/rinterface/sexp.c: In function ‘Sexp_init’:
./rpy/rinterface/sexp.c:742: warning: unused variable ‘copy’
./rpy/rinterface/_rinterface.c: In function ‘EmbeddedR_init’:
./rpy/rinterface/_rinterface.c:1393: error: ‘rl_completer_word_break_characters’ undeclared (first use in this function)
./rpy/rinterface/_rinterface.c:1393: error: (Each undeclared identifier is reported only once
./rpy/rinterface/_rinterface.c:1393: error: for each function it appears in.)
./rpy/rinterface/_rinterface.c:1396: error: ‘rl_basic_word_break_characters’ undeclared (first use in this function)
error: command 'gcc' failed with exit status 1

解决办法:

[root@localhost rpy2-2.8.5]# yum install readline-devel
Loaded plugins: fastestmirror, refresh-packagekit, security
Setting up Install Process
Loading mirror speeds from cached hostfile
 * base: mirrors.btte.net
 * extras: mirrors.zju.edu.cn
 * updates: mirrors.zju.edu.cn
Resolving Dependencies
--> Running transaction check
---> Package readline-devel.x86_64 0:6.0-4.el6 will be installed
--> Processing Dependency: ncurses-devel for package: readline-devel-6.0-4.el6.x86_64
--> Running transaction check
---> Package ncurses-devel.x86_64 0:5.7-4.20090207.el6 will be installed
--> Finished Dependency Resolution

Dependencies Resolved

=======================================================================================================================================================================
 Package                                    Arch                               Version                                          Repository                        Size
=======================================================================================================================================================================
Installing:
 readline-devel                             x86_64                             6.0-4.el6                                        base                             134 k
Installing for dependencies:
 ncurses-devel                              x86_64                             5.7-4.20090207.el6                               base                             641 k

Transaction Summary
=======================================================================================================================================================================
Install       2 Package(s)

Total download size: 776 k
Installed size: 2.0 M
Is this ok [y/N]: y
Downloading Packages:
(1/2): ncurses-devel-5.7-4.20090207.el6.x86_64.rpm                                                                                              | 641 kB     00:00     
(2/2): readline-devel-6.0-4.el6.x86_64.rpm                                                                                                      | 134 kB     00:00     
-----------------------------------------------------------------------------------------------------------------------------------------------------------------------
Total                                                                                                                                  1.2 MB/s | 776 kB     00:00     
Running rpm_check_debug
Running Transaction Test
Transaction Test Succeeded
Running Transaction
  Installing : ncurses-devel-5.7-4.20090207.el6.x86_64                                                                                                             1/2 
  Installing : readline-devel-6.0-4.el6.x86_64                                                                                                                     2/2 
  Verifying  : ncurses-devel-5.7-4.20090207.el6.x86_64                                                                                                             1/2 
  Verifying  : readline-devel-6.0-4.el6.x86_64                                                                                                                     2/2 

Installed:
  readline-devel.x86_64 0:6.0-4.el6                                                                                                                                    

Dependency Installed:
  ncurses-devel.x86_64 0:5.7-4.20090207.el6                                                                                                                            

Complete!
[root@localhost rpy2-2.8.5]# 
原文地址:https://www.cnblogs.com/RaymondBlog/p/6526309.html