在ubuntu gcc错误中安装pip geoip

 就是!有梦想 发布于 2022-12-20 13:08

我试图在python pip中在ubuntu中安装geoip ...但是有同样的gcc错误

pip install GeoIP

gcc -pthread -fno-strict-aliasing -DNDEBUG -g -fwrapv -O2 -Wall -Wstrict-prototypes - fPIC -I/usr/include/python2.7 -c py_GeoIP.c -o build/temp.linux-i686-2.7/py_GeoIP.o -fno- strict-aliasing

py_GeoIP.c:23:19: fatal error: GeoIP.h: No such file or directory

compilation terminated.

error: command 'gcc' failed with exit status 1

如何在ubuntu中解决这个问题

1 个回答
  • 您需要安装该libgeoip-dev软件包.

    $ easy_install GeoIP
    Searching for GeoIP
    Reading https://pypi.python.org/simple/GeoIP/
    ...
    py_GeoIP.c:23:19: fatal error: GeoIP.h: No such file or directory
     #include "GeoIP.h"
                       ^
    compilation terminated.
    error: Setup script exited with error: command 'x86_64-linux-gnu-gcc' failed with exit status 1
    Returned 1.
    
    
    $ apt-cache search geoip
    ...
    libgeoip-dev - Development files for the GeoIP library
    ...
    
    
    andrew@refbuntu:~$ sudo apt-get install libgeoip-dev -y
    [sudo] password for andrew: 
    Reading package lists... Done
    Building dependency tree       
    Reading state information... Done
    The following NEW packages will be installed:
      geoip-bin libgeoip-dev
    0 upgraded, 2 newly installed, 0 to remove and 159 not upgraded.
    ...
    Setting up libgeoip-dev (1.5.1-1ubuntu1) ...
    andrew@refbuntu:~$ easy_install GeoIP
    ...
    Running GeoIP-1.3.2/setup.py -q bdist_egg --dist-dir /tmp/easy_install-rwdpkL/GeoIP-1.3.2/egg-dist-tmp-DLLeBT
    /usr/lib/python2.7/distutils/dist.py:267: UserWarning: Unknown distribution option: 'bugtrack_url'
      warnings.warn(msg)
    warning: no files found matching 'ChangeLog'
    zip_safe flag not set; analyzing archive contents...
    Adding GeoIP 1.3.2 to easy-install.pth file
    
    Installed /home/andrew/.local/lib/python2.7/site-packages/GeoIP-1.3.2-py2.7-linux-x86_64.egg
    Processing dependencies for GeoIP
    Finished processing dependencies for GeoIP
    

    如果安装apt-file软件包,还可以按文件名搜索包含该文件的软件包:

    $ apt-file search GeoIP.h
    libgeoip-dev: /usr/include/GeoIP.h
    

    这对于因缺少依赖性而失败的任何安装/编译过程非常方便.

    2022-12-20 13:10 回答
撰写答案
今天,你开发时遇到什么问题呢?
立即提问
热门标签
PHP1.CN | 中国最专业的PHP中文社区 | PNG素材下载 | DevBox开发工具箱 | json解析格式化 |PHP资讯 | PHP教程 | 数据库技术 | 服务器技术 | 前端开发技术 | PHP框架 | 开发工具 | 在线工具
Copyright © 1998 - 2020 PHP1.CN. All Rights Reserved 京公网安备 11010802041100号 | 京ICP备19059560号-4 | PHP1.CN 第一PHP社区 版权所有