首页
学习
活动
专区
圈层
工具
发布
社区首页 >问答首页 >如何在IP2Location库中编辑setup.py

如何在IP2Location库中编辑setup.py
EN

Stack Overflow用户
提问于 2012-12-11 06:37:10
回答 1查看 439关注 0票数 0

我正在尝试使用IP2Location库,但目前还没有成功

这就是我应该做的,为了让它工作:

代码语言:javascript
复制
Download IP2Location C library at here.
Decompress C library.
tar ip2location-c-x.x.x.tar.gz
Download and decompress Python library.
tar ip2location-python-x.x.x.tar.gz
Get into working directory.
cd ip2location-python-x.x.x
Edit setup.py to point library_dirs and include_dirs ponting to IP2Location C library folder.
Start compilation.
python setup.py build && python setup.py install

这就是我的setup.py的外观:从distutils.core导入设置,扩展

代码语言:javascript
复制
module1 = Extension('IP2Location',
                    sources = ['IP2Location.c'],
                    libraries = ['IP2Location'],
            library_dirs = ['../ip2location-c-4.0.2/libIP2Location/.libs'],
            include_dirs = ['../ip2location-c-4.0.2/libIP2Location'])

setup (name = 'Python-IP2Location',
       version = '4.0.0',
       description = 'Python wrapper for IP2Location C API',
       ext_modules = [module1]

这是我的文件夹:

代码语言:javascript
复制
john-the-ripper@johntheripper-PORTEGE-Z835:~/PR$ ls -l
total 44
drwxrwxrwx 5 root            root             4096 Jan 26  2011 ip2location-c-4.0.2
drwxrwxrwx 4 root            root             4096 Dec 10 17:30 ip2location-python-4.0.0

这就是错误:

代码语言:javascript
复制
john-the-ripper@johntheripper-PORTEGE-Z835:~/PR/ip2location-python-4.0.0$ python setup.py build && python setup.py install
running build
running build_ext
building 'IP2Location' extension
gcc -pthread -fno-strict-aliasing -DNDEBUG -g -fwrapv -O2 -Wall -Wstrict-prototypes -fPIC -I../ip2location-c-4.0.2/libIP2Location -I/usr/include/python2.7 -c IP2Location.c -o build/temp.linux-i686-2.7/IP2Location.o
IP2Location.c:18:20: fatal error: Python.h: No such file or directory
compilation terminated.
error: command 'gcc' failed with exit status 1
john-the-ripper@johntheripper-PORTEGE-Z835:~/PR/ip2location-python-4.0.0$ 
EN

回答 1

Stack Overflow用户

发布于 2012-12-11 06:38:42

你需要python.h ..。您可以从python-devel包中获得它。

票数 0
EN
页面原文内容由Stack Overflow提供。腾讯云小微IT领域专用引擎提供翻译支持
原文链接:

https://stackoverflow.com/questions/13810504

复制
相关文章

相似问题

领券
问题归档专栏文章快讯文章归档关键词归档开发者手册归档开发者手册 Section 归档