【问题标题】:Pyhunspell installation in virtualnev在 virtualnev 中安装 Pyhunspell
【发布时间】:2013-12-22 12:05:43
【问题描述】:

我在 python 3.2 virtualenv 中为 hunspell 库安装 pyhunspell 绑定时遇到问题。我从here 下载了hunspell。我发出了./configuremake,它运行良好。但是我避免使用make install,因为我的目的是将它安装在我没有 root 权限的 web 服务器上的 virtualenv 上。

因此,我下载了pyhunspell bindings 并将其解压缩到创建 hunspell 的目录。我通过添加正确的目的地修改了setup.py 中的include_dir 路径并应用了patch,它允许使用Python 3 构建pyhunspell。然后我运行python setup.py install(之前激活了目标virtualenv),但我得到了这个:

$ python setupy.py install
running install
running build
running build_ext
building 'hunspell' extension
gcc -pthread -DNDEBUG -g -fwrapv -O2 -Wall -Wstrict-prototypes -D_FORTIFY_SOURCE=2 -g -fstack-protector --param=ssp-buffer-size=4 -Wformat -Werror=format-security -fPIC -D_LINUX -I./src/hunspell -I/usr/include/hunspell -I/usr/include/python3.2mu -c hunspell.c -o build/temp.linux-x86_64-3.2/hunspell.o -Wall
creating build/lib.linux-x86_64-3.2
gcc -pthread -shared -Wl,-O1 -Wl,-Bsymbolic-functions -Wl,-z,relro build/temp.linux-x86_64-3.2/hunspell.o -lhunspell-1.2 -o build/lib.linux-x86_64-3.2/hunspell.cpython-32mu.so
/usr/bin/ld: cannot find -lhunspell-1.2
collect2: error: ld returned 1 exit status
error: command 'gcc' failed with exit status 1

似乎链接器无法链接某些东西,因为它在系统路径中查找它,而我没有在系统中安装库。在 C 的奥秘中比我更聪明的人可以设计任何解决这个问题的方法吗?

我要补充一点,我还无法访问真实服务器,但我知道它的系统与我的本地系统(Debian 7.0 Wheezy)非常相似,所以我决定在实际使用之前尝试一下登录到服务器。假设它也是 Debian 的某个(可能是稳定的)版本,在我的计算机上编译的库是否也可以在服务器上运行?

【问题讨论】:

标签: linux python-3.x virtualenv hunspell


【解决方案1】:

无需构建 Hunspell。安装 Wheezy 软件包 libhunspell-1.3-0libhunspell-dev。它应该适用于 HunSpell 1.3。只需修改setup.py 以使用libraries = ['hunspell']


仅供参考,发布的补丁有问题。它将HunSpell 的方法添加为模块函数。它们接收模块作为第一个参数,而不是预期的 HunSpell 实例。例如,如果您调用hunspell.spell,则该进程在尝试使用self->handle 时可能会出现段错误。您应该修复PyModuleDef 以消除这些故障。将 hunspell.c 的第 273 行更改为使用 NULL 而不是 HunSpell_methods

【讨论】:

  • 奇怪,因为我在存储库中查找了 hunspell,但什么也没找到。但是现在,当您提供完整的包名时,我发现它们确实在那里。我希望它们将安装在服务器上。也感谢您提供有关补丁的信息。我会解决的。
猜你喜欢
  • 1970-01-01
  • 1970-01-01
  • 2012-04-26
  • 1970-01-01
  • 2017-05-16
  • 2018-07-28
  • 1970-01-01
  • 1970-01-01
  • 2013-01-02
相关资源
最近更新 更多