python - pip geoip在ubuntu gcc中安装错误

标签 python gcc ubuntu-12.04 pip

我正在尝试在 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中解决这个问题

最佳答案

您需要安装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

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

关于python - pip geoip在ubuntu gcc中安装错误,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/25963409/

相关文章:

python - 用户警告 : Module _mysql was already imported from/usr/lib/pymodules/python2. 6/_mysql.so

python - 使用 Python 3.6 检查句子中是否存在某些字符串并用另一个字符串替换它们

c - GCC 如何初始化自动变量?它们保证为 0 吗?

在循环中创建线程

用gcc编译C文件得到x86汇编代码

python - 在 Django 中查询模型(两层深度)

hadoop - 使用hadoop配置配置单元

java - 如何在ubuntu服务器上设置gwt上传路径

linux - sed 命令返回错误

python - 如何在 Keras.Model 中获取 l2 正则化损失值?