gpt4 book ai didi

Python dev_appserver 无法导入 `.so` 文件(枕头)

转载 作者:太空宇宙 更新时间:2023-11-04 05:05:23 26 4
gpt4 key购买 nike

在我的 GAE 应用程序中,我尝试这样做:

from PIL import Image

得到这个:

Traceback (most recent call last):
...
File "/home/sheena/Workspace/Waxed/code/waxed_backend/src/waxed_backend/concerns/misc/views.py", line 57, in home
from PIL import Image
File "libs/PIL/Image.py", line 56, in <module>
from . import _imaging as core
File "/home/sheena/Workspace/Waxed/venvs/wxt_comp/google-cloud-sdk/platform/google_appengine/google/appengine/tools/devappserver2/python/sandbox.py", line 1024, in load_module
raise ImportError('No module named %s' % fullname)
ImportError: No module named PIL._imaging

/path/to/libs/PIL/imaging.so 存在。而且我从 dev_appserver 中的 libs 文件导入任何其他东西都没有问题。

这很好用:

cd /path/to/libs/
python
>>> from PIL import Image

我只能得出结论,dev_appserver 以某种方式破坏了 importrt 功能,因此无法识别 .so 文件。

有没有人见过这个?知道如何解决吗?

最佳答案

_imaging 是一个用 C 编写的 PIL 依赖项。因为它是 C 而不是 Python,所以将库包含在您的 lib 文件夹中将不起作用。您需要在 app.yaml 文件中定义该库:

libraries:
- name: PIL
version: latest

关于Python dev_appserver 无法导入 `.so` 文件(枕头),我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/44654458/

26 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com