Pyinstaller隐藏另一个文件夹中的PIL模块

发布于 2025-01-21 13:47:39 字数 648 浏览 1 评论 0原文

我跟随我的pyinstaller汇编中的文件,从108个文件/文件夹到6。图像,我也很想隐藏该文件夹。

我已经尝试将其添加到sys.path在我的钩子中,将导入更改为from lt; fordernamehere> .pil import Import Import Image Image,然后在之前设置OS.Chdir在进口之后,但什么都没有起作用。错误始终是相同的:

Importerror:无法从'pil'(< pathtobasefolder> \ pil \ pil \ __ init __ init __. pyc)

要注意的一件重要的事情是,我不导入pil PIL立即地。当用户执行特定操作时,它仅在启动后才导入,因为它没有其他目的。我不确定会影响事物有多大的影响。

这可能吗?也许可以使用Ementlib,或者编辑Pyinstaller的本地钩子会起作用?

I followed this post to hide the vast majority of the files in my PyInstaller compilation, going from 108 files/folders to just 6. But one of those 6 is the PIL folder, since you have to do a from-import on it to access Image, and I would love to hide that folder as well.

I've experimented with adding it to sys.path in my hook, changing my imports to from <foldernamehere>.PIL import Image, and setting os.chdir immediately before and after the import but nothing has worked. The error is always the same:

ImportError: cannot import name '_imaging' from 'PIL' (<pathtobasefolder>\PIL\__init__.pyc)

One important thing to note is that I do not import PIL immediately. It's only imported after launch when the user performs specific actions, since it serves no purpose otherwise. I'm not sure how much that affects things.

Is this possible? Maybe importlib can be used, or maybe editing PyInstaller's native hooks would work?

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(1

此生挚爱伱 2025-01-28 13:47:39

使用以下命令:pip install -u枕头

Use the following command : pip install -U Pillow

~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文