Pillow: 未定义符号: PyCapsule_New
我有以下的前提条件:
- CentOS 6.5 操作系统
- 安装了 Python2.7,使用的命令是
./configure --prefix=/usr/local --enable-unicode=ucs4; make; make altinstall;
- 用 httpd 作为 Django 网站的网络服务器
我遇到了这样的错误信息:
...
File "/var/www/html/mysite.com/mylib/uploader/fields.py", line 8, in <module>
from PIL import Image
File "/var/www/html/mysite.com/eggs/Pillow-2.4.0-py2.7-linux-x86_64.egg/PIL/Image.py", line 53, in <module>
File "/var/www/html/mysite.com/eggs/Pillow-2.4.0-py2.7-linux-x86_64.egg/PIL/_imaging.py", line 7, in <module>
File "/var/www/html/mysite.com/eggs/Pillow-2.4.0-py2.7-linux-x86_64.egg/PIL/_imaging.py", line 6, in __bootstrap__
ImportError: /tmp/python-eggs/Pillow-2.4.0-py2.7-linux-x86_64.egg-tmp/PIL/_imaging.so: undefined symbol: PyCapsule_New
当我在 Django 的命令行中执行 from PIL import Image
时,没有出现错误。
我在网上搜索这个错误,但没有找到太多帮助,请大家帮忙。
更新:
我尝试用 Django 自带的服务器(manage.py runserver
命令)来运行网站,结果一切正常。
1 个回答
0
我遇到过类似的问题。
发生的情况是,我的python2.7安装在从系统的python2.6中获取包(通过一些PYTHONPATH的设置搞混了)。
为了调试,可以在被导入的东西之前设置一个断点,然后:
import sys
for path in sys.path:
print(path)
理想情况下,这里应该只包含python2.7的内容,但你可能不小心把python2.6的东西混进来了(或者反过来也有可能)。