将 PIL 从 Snow Leopard 上的站点包符号链接到无站点包的 virtualenv 不起作用
我有一个带有 --no-site-packages
的 virtualenv,并且在 virtualenv 中安装 PIL 时遇到各种问题。全球 PIL 运行良好。我试图通过符号链接到全局站点包中的 PIL 来实现此功能,我知道这是可行的。我尝试过:
ln -s /Library/Python/2.6/site-packages/PIL ~/my_virtualenv/lib/python2.6/site-packages/PIL
当我尝试从 Python 导入 PIL 时,效果很好。但是我无法运行 import Image
但这适用于系统 Python。我也尝试过批量复制目录,但也没有骰子。
关于如何调试这个有什么想法吗? PIL如何将Image导出到全局“模块空间”?
更新:感谢@Sentinel的坚持,我才能够解决这个问题。在安装 PIL 时检查跟踪,我注意到一堆像这样的行:
ld: warning: in /opt/local/lib/libjpeg.dylib, missing required architecture ppc in file
ld: warning: in /opt/local/lib/libz.dylib, missing required architecture ppc in file
这些实际上是剩下的所有错误,但最初还有其他人抱怨我没有适用于 i386 或 x64 架构的 libjpeg。因此,我备份并删除了安装到 /usr/local/lib
的 libjpeg,然后使用 macports 来安装通用二进制文件(基本上遵循 http://passingcuriosity.com/2009/installing-pil-on-mac-os-x-leopard/ )。考虑到这就是导致问题的原因,libjpeg 没有针对我需要的架构进行编译。完成此操作后,我安装了成像库,然后一切正常 - 不需要符号链接。现在我可以上床睡觉了,不再想这个,即使花了 4 个小时才弄清楚。 :)
I have a virtualenv with --no-site-packages
and am having all sorts of issues installing PIL in the virtualenv. The global PIL works fine. I'm trying to get this working by symlinking to PIL in the global site packages, which I know works. I tried:
ln -s /Library/Python/2.6/site-packages/PIL ~/my_virtualenv/lib/python2.6/site-packages/PIL
When I then try to import PIL
from Python, that works fine. However I can't run import Image
but this works for the system Python. I also tried just copying the directory wholesale, but no dice there either.
Any ideas on how to debug this? How does PIL export Image to the global "module space?"
Update: Thanks to @Sentinel's persistance, I was able to solve this problem. Examining the trace when installing PIL, I noticed a bunch of lines like so:
ld: warning: in /opt/local/lib/libjpeg.dylib, missing required architecture ppc in file
ld: warning: in /opt/local/lib/libz.dylib, missing required architecture ppc in file
Those are actual all the errors that are left, but originally there were others complaining about how I didn't have libjpeg for i386 or x64 architectures as well. So I backed up, removed the libjpeg I had installed to /usr/local/lib
and just used macports to install the universal binaries (basically following the instructions at http://passingcuriosity.com/2009/installing-pil-on-mac-os-x-leopard/). Figuring this is what was causing the problem, libjpeg wasn't compiled for the architecture I needed. After doing that, I then installed the Imaging library and then everything worked -- no symlinking required. And now I can go to bed without thinking about this anymore, even if it took 4 hours to figure out. :)
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
安装开发库(jpeg、zip 等),然后使用 virtualenv(根据需要添加 setuptools 或 pip)将 PIL 安装到 virtualenv 本身中。
Install the development libraries (jpeg, zip, etc.), then use the virtualenv (adding setuptools or pip to it as necessary) to install PIL into the virtualenv itself.