在多个系统上使用PIL [英] Using PIL on multiple systems

查看:84
本文介绍了在多个系统上使用PIL的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

在以下情况下寻找一些建议和最佳实践指导.我有一个从源代码运行的python应用程序,其中包括所有依赖项.使用PIL时会出现一些问题.不同的python版本需要不同的PIL源,而64位和32位需要不同的版本.

looking for some advice and best practice guidance with the following situation. I have a python application that is run from source and has all dependencies included. When using PIL some issues arise. Different python versions need different PIL sources and 64 bit and 32 bit need different version.

我们已决定要支持:

Python 2.4 64位

Python 2.4 64 bit

Python 2.4 32位

Python 2.4 32 bit

Python 2.7 64位

Python 2.7 64 bit

Python 2.7 32位

Python 2.7 32 bit

我将必须找到必要的源软件包并将其全部包含在内.问题是什么是导入它们的最佳方法?我是否要检查python版本和OS版本并基于该版本导入不同的PIL版本(是否可以导入其他内容?)还是可以一次全部导入?

I will have to locate the necessary source packages and include them all. The question is what is the best way to import them? Do I check python version and OS version and import different PIL versions based on that (can you if, else import stuff?) or can I import once for all?

希望这一切都有道理.谢谢

Hope that all makes sense. Thanks

推荐答案

我将采取与@alan答案相反的方向,并且不建议您甚至分发4种这样的硬编码环境.

I'm going to take the opposite direction of @alan's answer and not recommend you even distribute your 4 hard-coded environments like that.

如果直接分发源代码,则根本不应该包含预构建的依赖项.创建某种 setup.py 以下载并安装依赖项.或者考虑将您的应用打包到一个独立的可执行文件中

If you are distributing source code directly, then you shouldn't be including prebuilt dependencies at all. Create some kind of setup.py to have the dependencies downloaded and installed. Or consider packaging your app into a self-contained executable

您的软件包可能在本地包含PIL的安装文件,因此不需要下载,但应由实际的最终用户构建以匹配其体系结构.试图使您的应用程序解决所有这些问题并指向许多预编译的软件包之一没有任何意义.

Your package could contain the setup files for PIL locally so a download wouldn't be needed, but they should get built by the actual end-user to match their architecture. There is no point in trying to make your application figure all of this out and point to one of many precompiled packages.

如果您想为包含整个环境的不同系统创建可自行执行的软件包,还可以查看py2exe,py2app和pyinstaller.

You can also take a look at py2exe, py2app, and pyinstaller if you want to go the route of creating self-executable packages for different systems that contain their entire environment.

这篇关于在多个系统上使用PIL的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆