【发布时间】:2017-04-27 15:05:45
【问题描述】:
我正在运行一个带有 ubuntu 14 的 linux 机器,它运行一个托管 Django 应用程序的 apache2 服务器。 此应用程序从已安装的 Pillow 库中导入 PIL。当我使用 Python 3.5 时一切正常,但是在升级到 Python 3.6 并在 Virtualenv 中重新安装 Pillow 后,当网络服务器尝试导入 PIL 时出现错误。
当我运行 Python 解释器时,它全部导入正常,因为它直接使用 py 脚本,但是由于网络服务器正在使用已安装和编译的枕头库,它失败了。来自 Django 的错误显示堆栈如下:
Internal Server Error: /ticket-printing/
Traceback (most recent call last):
File "/home/ubuntu/ipos-venv/lib/python3.6/site-packages/django/core/handlers/exception.py", line 41, in inner
response = get_response(request)
File "/home/ubuntu/ipos-venv/lib/python3.6/site-packages/django/core/handlers/base.py", line 249, in _legacy_get_response
response = self._get_response(request)
File "/home/ubuntu/ipos-venv/lib/python3.6/site-packages/django/core/handlers/base.py", line 187, in _get_response
response = self.process_exception_by_middleware(e, request)
File "/home/ubuntu/ipos-venv/lib/python3.6/site-packages/django/core/handlers/base.py", line 185, in _get_response
response = wrapped_callback(request, *callback_args, **callback_kwargs)
File "/home/ubuntu/ipos/tickets/views.py", line 30, in stic_app
PrintList.initiateSticApp(request)
File "/home/ubuntu/ipos/tickets/models.py", line 434, in initiateSticApp
BrandLogo.createBlankLogo()
File "/home/ubuntu/ipos/store_admin/brands/models.py", line 108, in createBlankLogo
from PIL import Image
File "/home/ubuntu/ipos-venv/lib/python3.6/site-packages/Pillow-4.1.0-py3.6-linux-x86_64.egg/PIL/Image.py", line 56, in <module>
from . import _imaging as core
File "/home/ubuntu/ipos-venv/lib/python3.6/site-packages/Pillow-4.1.0-py3.6-linux-x86_64.egg/PIL/_imaging.py", line 7, in <module>
__bootstrap__()
File "/home/ubuntu/ipos-venv/lib/python3.6/site-packages/Pillow-4.1.0-py3.6-linux-x86_64.egg/PIL/_imaging.py", line 6, in __bootstrap__
imp.load_dynamic(__name__,__file__)
ImportError: /home/ubuntu/ipos-venv/lib/python3.6/site-packages/Pillow-4.1.0-py3.6-linux-x86_64.egg/PIL/_imaging.cpython-36m-x86_64-linux-gnu.so: undefined symbol: PySlice_AdjustIndices
我尝试通过 pip、easy_install 和 tar.gz setup.py 方法卸载、重新安装 Pillow,但都失败了。
任何指导和帮助将不胜感激。
谢谢
【问题讨论】:
-
您的 Pillow 版本是什么?使用 Python 3.6.x 安装特定版本时可能会遇到兼容性问题:pillow.readthedocs.io/en/4.1.x/installation.html#notes 我使用的是 virtualenv,我猜你的 requirements.txt 中有特定的旧 Pillow 版本。
-
我尝试了 4.0.0 和 4.1.0,前者在 Python 3.5 上运行良好
标签: python django apache pillow python-3.6